![]() ![]() It contains: HumanPlayer(const std::string& name): The constructor of the HumanPlayer which receives the name of the player, and passes it to its parent class's constructor Card getCard: prompts the user for the Card they want to play by Displaying the cards in the user's hand Prompting the user to select a card (either as an index, or allow the user to enter their card using the same values used when printing cards) Validates the user selected a valid card, and reprompts the user until a valid option is selected ComputerPlayer This class is an abstract base class derived from the class Player. HumanPlayer This class is derived from the class Player. ![]() A card is valid if it matches the same suit as suit or if there's no cards in the player's hand with a matching suit (a None suit allows the user to select any Suit of card except Heart, unless broken is true, in which case a Heart is valid). bool isValid(Suit suit, bool broken, const Card &card): Returns true if the card is a valid selection. Card getCard(Suit suit, bool broken): This is a pure virtual function that makes the players select a card. The interface contains the following member functions: Player(const std::string& name): The constructor of the Player class receives the name of the player. It stores the name of the player in a constant string, which is public, and a protected list of cards the user current has in their hand. Player Player is an abstract base class for the common functionality of human and computer players. For testing purposes, you may want to overload the operator<<, to ensure you are properly creating and shuffling the deck though this is not required. A constructor, which calls the reset method A reset method, which adds all 52 cards to the deck, then shuffles the cards randomly (hint: use std::shuffle) A draw method, which removes the top card from the deck, and returns it. The deck contains: An appropriate datastructure (see above) to contain all the cards remaining in the deck. of your choosing to contain all the cards with a deck. You may use a vector, queue, linked_list, etc. Deck The deck represents a deck of cards. A card can be implemented entirely in a header file, as a struct. The None option should generally not be used, and is only used for the Player's getCard function (see below). Use the appreviations of A for Ace (1), J for Jack (11), Q for Queen (12), and K for King (13) for suites, use S for Spades, H for Hearts, C for Clubs, and D for Diamonds. A possible definition for the suit is enum class Suit The card should overload the operator<< for easy printing, and should print in the form of H2 (for 2 of Hearts), DJ (for Jack of Diamonds), etc. Card A Card represents a playing card, and is represented by a constant for a value (1 to 13), and a constant enumerated type for the suit. The following types, classes and functions must be implemented. Equip the header files with include guards. Each class must have its own source code and header file. Implementation The program uses several classes. The design of the program shall make it possible to implement computer players of different strength however, only one (very simple) player is required for the project. (card_game)) on a computer (using rules listed at the bottom on this document). Develop a program to play the game Hearts (cf. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |