Question: Topics: Generics, Array List, Linked List. First Abstract Class: public abstract class Card { enum Rank{ ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE,

Topics: Generics, Array List, Linked List. Topics: Generics, Array List, Linked List. First Abstract Class: public abstract class

Card { enum Rank{ ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT,

NINE, TEN, JACK, QUEEN, KING; } enum Suit{ HEARTS, CLUBS, DIAMONDS, SPADES;

} protected Rank rank; protected Suit suit; public Card(Rank r, Suit s){

rank = r; suit = s; } public Rank getRank(){ return rank;

} public Suit getSuit(){ return suit; } abstract boolean equals(Card c); abstract

int getPoints(); @Override public abstract String toString(); } Second Abstract Class: public

First Abstract Class:

public abstract class Card {

enum Rank{

ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING;

}

enum Suit{

HEARTS, CLUBS, DIAMONDS, SPADES;

}

protected Rank rank;

protected Suit suit;

public Card(Rank r, Suit s){

rank = r;

suit = s;

}

public Rank getRank(){

return rank;

}

public Suit getSuit(){

return suit;

}

abstract boolean equals(Card c);

abstract int getPoints();

@Override

public abstract String toString();

}

Second Abstract Class:

public abstract class Board {

protected Player currentPlayer;

protected int numPlayer;

protected Deck deck;

protected Hand cardOnBoard;

public Board(Deck deck){

this.currentPlayer = null;

this.numPlayer = 0;

this.deck = deck;

}

abstract Player getCurrentPlayer();

abstract int getNumPlayers();

abstract Deck getDeck();

abstract boolean changeTurn();

abstract void addPlayer(Player x);

}

You are going to build a small card game called SWITCH uning expendable aay and linked nt You wl be giren trwo abstract classes-Card and Board, from which you will implement the game specific clanes- Cardswitch and BoardSwitch. You mill also implement an acay iat-like data structuce that keeps track of the eards in a playe's hand. This is the Hand class, used to repcesent a Player and a Deck. The Board class maintains a linked list-like data structuce that keeps track of all players in the game and decides the winner of the game You are zequired to complete the JavaDoc comments for ALL classes including the ones you did not implement (except for PlaySwitch). As part of understanding this peoject, stast with wating JaraDoe comments for the classes that ace implemented for you: Card, Deck, and Board. Yes, you will be graded on this, and yes, you need to add comments to the methods and instance vaciables. Step 2: Implementing and Understanding the Code There is a total of 7 classes in the project Howere, you are only sequired to implement some of them. See the project stacter package for all the Eles The abstract Card Class (see Card.java) [code providedi should not be modified except for adding JavaDoe comments A card consists of ank and suit A regular deck of 52 cards contains 13 diffecent ranks and 4 diffecent suits. Ranks consist of ACE, IWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE TEN, JACK, QUEEN, and KING Suits consist of HEARTS, CLUBS DIAMONDS, and SPADES. In our design, every card has a point and a poonity which should be implemented in its inheited classes The CardSwitoh Class (see CardSwitch.java) Wate a class specific to the game SWITCH by extending the abstract class Card. Required methods public Cardswitch (Rank rank, Suit suit) Ceate a card with a given ank and suit . public int getPoints () . Retuns an integer according to the point of this card.ACE-1 point, 2- 2 points, 3-3 points, ,9-9 points, (10, JACK, QUEEN, KING) -10 points each public boolean equals (Card anothercard) . Retuens true if the card is of the same rank and suit of another Cand public String toString ) Ratom a stang representation of the card in the fom of RankSuit) with all capital letters and no space. For example: (KING, SPADES) o CEIGHT, HEARTS)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!