The Card Class
blue.cards.Card
Constructors
new Card (< int >, < string >) -- >
< Card >
new Card (< string >, < string >) -- >
< Card >
Methods
< Card > .print ()
< Card > .println ()
< Card > .rank () -- >
< int >
< Card > .suit () -- >
< int >
Constants
Card.JACK -- >
< int >
Card.QUEEN -- >
< int >
Card.KING -- >
< int >
Card.ACE -- >
< int >
Card.CLUB -- >
< int >
Card.DIAMOND -- >
< int >
Card.HEART -- >
< int >
Card.SPADE -- >
< int >
Suppose....
x and y are card objects
1.. display the rank of x.
IO.println (x.rank ());
note: this will give an integer representation
2.. Do a better job of # 1..
x.printRank ();
3.. Display the suit of x.
x.printSuit ();
4.. Display both cards, one per line
x.println ();
y.println ();
5.. Display the word ``red'' if x is a red card.
boolean xHeart = (x.suit () == Card.HEART);
boolean xDiamond = (y.suit () == Card.DIAMOND);
if (xHeart
| |
xDiamond)
{
IO.println (``red'');
}
|