Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Answer the following based on information provided after the question. When revi

ID: 3822748 • Letter: A

Question

Answer the following based on information provided after the question.

When reviewing the game of Three Card War how would we break down the game into it's basic elements?

What C++ classes would we need to implement the game?

Identify these basic classes, choose a class and describe how you might implement the .h file with the appropriate member functions for the class.

Three Card War

The card game Three Card War is a simple card game for two players. The game uses a 52 card conventional deck. To begin the deck is shuffled and each player draws three cards. The players may look at their three cards. The remaining cards are placed in a pile facedown between the two players. The players decide who is going first.

• The player going first selects one of his three cards and places it faces up.

• The opposing player selects one of her three cards and places it faces up.

• If the ranks of both cards are the same (a push), then both players retain their cards and set them aside. Otherwise, the player with the highest-ranking card keeps both cards (again, setting them aside)

• After playing the round, each player draws one card from the deck to replace the card just played with the first playing drawing first.

• The player that won the round is now the first player for the next round unless there was a push then the original first player goes frst again.

• The game ends when the deck is exhausted and both players have played all of their three cards

. • The player with the most cards set aside wins. Card ranking begins with the 2 as the lowest card going up to the ten, then jack, queen, king, and ace.

Explanation / Answer

1. Card class with just an int instance for storing it's rank from 2 to 14 (Ace) as suits are meaningless in this case , a method to getRank and setRank each .

2. Player class with instance variable card in hand an array of three Card class instances and another int instance of count of cards won . With methods like show cards to show cards in hand , addcard to cards in hand , removecard from card in hand , showcount of cards won .

3. Game class with two player class instances , an array of 52 card class instances ,an instance to count the number of cards played , a method to shuffle the card deck , a method to draw card , a method to remove cards used from deck, a method to compare cards , a method to showturn to play .

Putting each class in it's own header for low coupling and easier maintenance . eg.


#ifndef TCW_CARD_H__
#define TCW_CARD_H__


using namespace std;
namespace tcw{
class Card {

private:
int rank ;

public:
Card(int r) ;

Card();
int getRank();
void setRank(int r);
};
};
#endif