Create the following classes:
String suite
String faceValue
Card(String suite, String faceValue)
- set the parameter fields to the instance fields
- Create a getter method called
String getSuite
to return the suite of the card. The return type is String. - Create a setter method called
void setSuite(String newSuite)
and set thenewSuite
parameter to thesuite
field. There is no return type. - Create a getter method called
String getFaceValue
to return the face value of the card. The return type is String. - Create a setter method called
void setFaceValue(String newFaceValue)
and set thenewFaceValue
parameter to thefaceValue
field.
ArrayList<Card> cards
Deck()
- create an empty constructor. In the constructor, set the card field to a new instance of ArrayList.cards = new ArrayList<Card>()
- Create a getter method called
ArrayList<Card> getCards
to return the cards field. The return type is aArrayList<Card>
. - Create a method called
void addCard(Card card)
and add the card in the parameter to the field cards list. - Create a method called
int size()
which returns how many card is in the list. - Create a method called
Card draw()
which remove the card at index 0 from the list
String name
ArrayList<Card> hand
Player()
- create an empty constructor. In the constructor, set the hand field to a new instance of ArrayList.hand = new ArrayList<Card>()
- Create a getter method called
ArrayList<Card> getHand
to return the hand field. The return type is aArrayList<Card>
. - Create a method called
void takeCard(Card card)
and add the card in the parameter to the field hand list. - Create a getter method called
String getName
to return the name of the player. The return type is String. - Create a setter method called
void setName(String newName)
and set thenewName
parameter to thename
field. There is no return type.
Player player1
Player player2
Deck deck