Design the data structures for a generic deck of cards

Go down

Design the data structures for a generic deck of cards

Post  Admin on Wed Sep 07, 2011 3:44 pm

public class Card{
public enum Suit{
CLUBS(1), SPADES(2), HEARTS(3), DIAMONDS(4);
int value;
private Suit(int v){value=v;}
};

private int card;
private Suit suit;

public Card(int r, Suit s){
card=r;
suit=s;
}
public int value(){return card;}
public Suit suit(){return suit;}
}

public class BlackJackCard extends Card{
public BlackJackCard(int r, Suit s){ super(r,s);}

public int value(){
int r=super.value();
if(r==1) return 11;
if(r<10) return r;
return 10;
}
boolean isAce(){
return super.value()==1;
}

}

Admin
Admin

Posts : 131
Join date : 2011-08-16

View user profile http://codefornongeek.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum