![]() |
Assignment 16TaskBring together everything you've learned this semester into a final project: write a simple two-player game. RequirementsYou may pick which game you write. However, it needs to meet these requirements:
Keep in mind you will probably only have text output to work with. (If you want, you can construct a GUI interface, but there will be no extra credit for it. See EC1 if you want extra credit for making a GUI.) Internally, your program needs to also include the following:
Your game should also (briefly) explain to the user how to play when it starts. Possible GamesSome games are harder than others so, before you pick one, spend some time sketching out the steps you're going to need to implement to get the job done. Here are most of the games people are doing:
Steps for Old MaidIf you're stuck, consider the following design for Old Maid. PlayingCardWrite a PlayingCard class that holds a value and suit. (Based on the suit, you can also determine the color.) You will need the appropriate constructor, accessor and mutator methods, and toString. Deck (Optional)If you wanted to reused your Deck class from A13, you could. OldMaidIn main: First, explain the rules to the player. Create a new Deck of 52 shuffled cards. (If you're not using Deck, then just create an ArrayList of cards instead.) Deal the cards out into two hands (that is, into two ArrayList<PlayingCards>s). You don't need to alternate between hands as you deal; you can just draw 26 cards for one hand, and then 26 for the other. While dealing, if you draw the Queen of Clubs, discard it. (This technique means you don't need to go find the Queen before dealing, and that each hand has an equal chance of being the smaller hand.) Now go through both hands and remove all pairs--cards with the same value and same color. (This is the hardest part.) Let the user know which pairs were discarded from both hands by this process. Now the game can start. Show the player their hand. (There's not much they can do with it, though, so you might just want some sort of one-line representation.) Tell them how many cards their opponent has, and let them pick a number between 1 and that number. (This is the card they are drawing from their opponent's hand.) Match and discard the pair this forms. Then have the computer player randomly pick a card from the player's hand. Again, report what card this was and what discarded pair was formed. Repeat the previous two blocks--the player drawing and then the computer drawing--until one of the players runs out of cards. The other player should then be holding the Queen of Spades (the Old Maid) and is the loser. Note: Though possible, this program will be tricky to write if all of this is main. Try to look for things you could break out into methods. For instance, you could write a private static method that takes an ArrayList hand and a PlayingCard to match, and then finds, removes, and returns the matching card (if any) found in the hand. Design SummaryBy noon on 29 Apr 2008, send me a summary of what game you're planning to implement. Include:
If you'd also like to include more information--such as what collections you're planning to use, how you plan to break the problem down into classes and methods, etc--I will try to give you some feedback on your design or what problems might be tricky to handle. Don't send me code at this point though. If you're doing Old Maid as described above, then you just need to send me the name of the game. Sending me this information before the deadline will get you 1 point of extra credit. What to submitAttach all files needed to run your program to an email. This will be a studio project, so please include your name as part of all class names. FAQs
GradingOut of 20 points:
|
~ztomasze Index :
TA Details: ICS111:
Assignment 16 http://www2.hawaii.edu/~ztomasze |
Last Edited: 22 May 2008 ©2008 by Z. Tomaszewski. |