Write a text-based implementation of Go Fish. Your program should allow 2-6 play
ID: 3665717 • Letter: W
Question
Write a text-based implementation of Go Fish. Your program should allow 2-6 players to play the game. Since there’s no concept of “to the dealer’s left” in this software version, you can make the first turn go to any player you wish. When a player takes his/her turn, your program should display a count of how many cards are left in the deck, as well as a summary of that player’s current hand and collected books, if any. When the game ends, determine and show the winning player(s) on the screen.
Your assignment must include the following classes:
- Card and Deck classes to represent an individual card and a deck of cards. You can use the Card and Deck classes from the poker example discussed in lecture as a starting point. However, you may need to add a little bit more functionality.
- A Player class to represent each player. This class should include (but is not limited to) the following parts:
-Instance variables:
-Player’s name
-Cards in the player’s hand
-Books that the player has collected
-Methods:
-Adding a card to the hand
-Removing cards from the hand that form complete books
-Transferring all cards of a specific rank to another Player object
A GoFish class to represent the entire set of players. This class should include (but is not limited to) the following parts:
- Instance variables:
-A Deck object
-An array of Player objects
- Methods
-Allowing a specific player to take his/her turn
-Checking whether the game is over
-Determining the winning player(s)
-A startGame() method similar to what we wrote in the poker and Nim examples. This method is what will get executed when you run your game. It should include things like allowing the user to specify the number of players, collecting each player’s name, allowing players to take turns until the game is over, etc
Note that all user input should be located only in the GoFish class. The idea is that the core game objects (cards, deck, etc.) should be independent of the game’s user interface. If you wanted to make a graphical version of Go Fish, you’d be able to use the existing classes and make changes only to GoFish!
Implement error checking on all user inputs, to the extent that was covered in COMP 1900. For example, you should include things like:
- Making sure the user can’t select fewer than 2 or greater than 6 players
- Making sure a player can’t ask him/herself for cards
- Making sure a player can’t request a rank that s/he does not have in his/her hand
Explanation / Answer
Please try this way..
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.