Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Write a research paper on Virtual Private network

Answered: 1 week ago

Question

9. Describe the characteristics of power.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago