瀏覽單個文章
Xforce
Senior Member
 
Xforce的大頭照
 

加入日期: Feb 2002
您的住址: 宜蘭
文章: 1,341
public class Card {

public enum Rank { DEUCE, THREE, FOUR, FIVE, SIX,
SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE }

public enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES }
private Rank rank; // the suit of a card
private Suit suit; // the rank of a card
private int value; // the actual value of a card

/**
* Class constructor
* The default Card constructor, creates a new Card object with default values.
*/
public Card()
{
suit = null;
rank = null;
value = 0;
}

/**
* Class constuctor
* Takes the suit, rank and value the card and create a Card object.
* The suit argument must be in either spade, heart, diamond or club. The
* value of rank argument must be chosen from Ace to K. The value argument must
* be an integer from 1 to 13.
* <p>
* One Card object will be created with the given parameters.
*
* @param suit the suit of the card
* @param rank the rank of the card
* @param value the value of the card
*/
public Card(String suit, String rank, int value)
{
this.suit = Suit.valueOf(suit);
this.rank = Rank.valueOf(rank);
this.value = value;
}

/**
* Get the suit of the card
* @return String
*/
public String getSuit()
{
return this.suit.toString();
}

/**
* Get the rank of the card
* @return String
*/
public String getRank()
{
return this.rank.toString();
}

/**
* Get the actual value of the card
* @return int
*/
public int getValue()
{
return this.value;
}

}
先搞清楚enum 怎麼用~~
__________________
AMD Athlon 64 3000+
Asus A8N-E nfoce 4 empowered
Simems DDR 400 512MB *2
Benq 1640
---------------------------------
舊 2006-09-28, 09:28 AM #15
回應時引用此文章
Xforce離線中