HW 1
The Mickey Mantle Card Game
One of the most important skills a software engineer can have is the ability to take a large problem, like a software specification, and view it as a series of small, easily solvable problems. For this assignment, do not simply dive into the coding, that is a recipe for failure. Instead, develop a plan for solving this problem. Break this assignment down into smaller problems. Do this by dividing the data into appropriate classes, and then deciding what methods are necessary for implementing the solutions to these smaller problems. Helper methods help!
Test as you go! I cannot emphasize it enough that you need to get used to testing your code as you go. Write a little bit of code (one method), and then make sure it works properly before moving on to the next one.
For this assignment, you will implement a program that plays the Mickey Mantle Card Game. This a fun card game, best with 4 players, that your humble instructor liked to play growing up. In your version of the game, there will only be at most one human player, and from 2 - 4 computer players. The user will get to select how many computer players, and if the user selects 4, there will be no human players (only bots).
Game Play
In this game, the winner will be the one who plays all their cards first. Playing a card means placing a card in its proper order onto one of the four suit piles. Note that players build the four piles out in both directions from the seven card (i.e. the middle of the suit). So the first card played in the game must be a seven. To play the game, first, all the cards are dealt out evenly to the players. Players then place cards on the suit piles in turn according to the following rules. For the player whose turn it is:
- If that player has a 7 (sevens always lead a pile), they may play that card on the applicable suit pile (i.e. the 7 of hearts would go on the hearts pile).
- Any other card can only be played on a pile if an adjacent card has already been played. So for example, a 9 of Spades can only be played if an 8 of Spades has already been played, and an 8 of Spades could only have been played if a 7 of Spades had already been played.
- If a player cannot play any cards, that player's turn is skipped.
- A player may not skip a turn if they have a card that can be played.
- Suit lists are not circular but an Ace may be played either after a 2 or a King. So, for example, we may have a Spades pile with A,2,3,4,5,6,7 or 7,8,9,10,J,Q,K,A, but not 7,8,9,10,J,Q,K,A,2.
Game Requirements
Code the Mickey Mantle Card Game such that it provides a game menu that allows a player to play the game as many times as one likes. In addition, it should allow for:
- New Game: When a player plays a new game, the program should ask the user how many Computer Players (i.e. AI, Artificial Intelligence) will be playing. The only valid choices should be 2-4. If the user enters 2, there will be one human player and 2 computer players. If the user enters 3 there should be one human and 3 computer players. If the user enters 4, there will be 4 computer players and no human players. Note that while the game is running, your program should ask the user for input to advance the game after each turn, whether it's a human turn or a computer turn. If it's a human turn, you'll have to ask the user for the card to play, if its a computer turn (or if the human's turn needs to be skipped), you just have to ask the user to type ENTER or something to continue. Note that when playing this type of game, the player should always know how many cards the other players have, but should not see their cards.
- New Game with Cheats: In this version of the game, the user should be allowed to see all the cards of all the players. This will help you when debugging.
- Viewing Player Record: You should maintain information about the number of games played, won, and lost by the human player, as well as the total number of cards left in the human players hand at the end of the games. This can be used to calculate the average cards left in the human players' hand. This information should be saved to a file whenever a game concludes and should be loaded whenever the game application starts. Note that we are not using player accounts, there is only one player, so you only need to store the record of that one player. The player should be able to view this data upon request.
- Random Card Selection: To speed up testing, add functionality to your program such that when its the human player's turn, one may ask the game to randomly select a card to play for them.
Coding Rules
- Which classes may you use?
- You may use any classes you like from the Java API to create your program. Note that we are making a console-based application, so all I/O is textual. You may not use classes written by anyone else, including your fellow classmates. This is something your instructor takes very seriously.
- How many classes do you need?
- This is up to you, however, you should use the principles of Object Oriented Programming to the fullest. The more code you place in classes for repeatedly used objects, the better. You may also consider using Java Collections framework classes like ArrayList for managing your arrays.
- Which file format may you use?
- You may use whatever file streams (i.e. textual, binary, etc.) and file formats you wish for this assignment.
No Crashing
Under no circumstances should your program terminate (crash) unless the player has requested to quit. You must handle all faulty user input in an intelligent way such that your game can recover from user error and continue. Note that your professor will try to break your program using all kinds of bad input.
NOTE: It is not likely you will be able to complete this assignment in one or even two nights. You must carefully think about all the components to this assignment and then break down the work into pieces that you can implement. Make sure to have some sort of design before you start, and again, make sure you test your code as you go. The intention here is to get you back in the flow of Java programming and get you thinking about data structures.
EXAMPLE SESSION
The MickeyMantleCardGameExampleSession.txt file provides an example of how your game application may look. You should use a similar menu.
Handin Instructions
When you are done, zip up and submit your project via Blackboard.
Grading
Note that grading for this assignment is done purely based on functionality and how closely your work resembles that of the example session. Code that does not compile will not receive credit and points will be deducted for each thing that does not work according to the requirement.
Web page created and maintained
by Richard McKenna
