Computer Science Canada Damn it! My Card game doesn't wanna work |
Author: | Ultra Jugulator [ Fri Nov 25, 2005 2:10 am ] | ||
Post subject: | Damn it! My Card game doesn't wanna work | ||
So, here is my program for my assignment due tomorrow:
But it doesn't work as the way it's being ask to work like. This is what my teacher asked me to do. "The 99 Game" 99 is a children's game used to encourage fast addition. 99 is played with a standard deck of playing cards. Any number can play but we will discuss three players. The rules of the game are simple. Each player is dealt 5 cards. One card is turned face up and forms a "pile" so that all players can see it. The players alternate putting cards on the pile and adding the card's value to the piles total, and drawing a new card from the deck to replace the one they discarded. The aim of the game is to continue to add cards to the pile as long as the pile never has a total larger than 99. Each card is worth the following; Ace == 1 2 == 2 3 == 3 4 == reverse the order of play 9 == 0 10 == 10 Jack == 10 Queen == -10 King == 99 For example if there were three players and a 2 were the first card on the pile and the first player put a jack on top then the total would be 12. If the second player put a Queen on the pile then the total would be 2 again. If the next card put on the pile by the third player was a nine than the total would remain 2. Play would continue with it being the first player's turn again. If the first player put a 4 on the pile, the total would remain 2 but the order of play would now reverse with it being the third player's turn. The order of play remains reversed until another 4 card is placed on the pile. If one of the players puts a King on the pile the total immediately becomes 99. The only valid cards that can be used by the other players at this point are 4, 9, Queen or King. The first player to make the pile go over 99 loses and play continues with the other players until only one player is left. You are to write a Java class called "Deck" that contains at least the methods to; "¢ Create the deck, "¢ Shuffle the deck, and "¢ Draw a card at a time from the deck. You are to write a Java class called "Pile" that has methods to add a card to the pile and a method that returns the total of the cards on the pile. Other methods are allowed if needed. You are to write a Java class called "Player" that contains at least the methods "¢ "play" to draw a card from the deck and to discard a card onto the pile "¢ "draw" to draw a card from the "Deck" class "¢ "discard" to put a card on the "Pile" class The constructor method for "Player" should allow you create 3 types of players; 1. A smart player that uses a defined strategy to win, 2. A naïve player that just plays by the rules, and 3. A human player where decisions are made by a human involved as one of the players when it is their turn. You are to write a Java driver class that: "¢ Creates a deck of cards, "¢ Creates 3 players, and "¢ Runs a game of 99 between the players until a winner is found. Make sure that the output from this driver can be easily understood by someone who wishes to follow the game. So, what exactily the program needs to work the game as it's being asked in the instructions? |