all hidden and exposed cards in each tableau pile (print "xx" for hidden cards).Before each turn, the program should print a representation of the game state showing Your program should shuffle the main deck, deal cards into the tableau piles, and then allow the user to play the game by repeatedly drawing the next card from the main deck, or moving exposed cards. When a card or cards are moved onto an empty tableau pile, the new bottom card must be a King.įollowing a move, the top card of the pile the card or cards were moved from is exposed (if the pile is not empty.) Progam requirements.Clubs and Spades are black suits, and Diamonds and Hearts are red suits. The colors of the cards in a tableau pile must alternate red and black.Instead, a chosen card and all cards on top of it must be moved. When multiple cards are moved (from a tableau pile), the cards cannot be removed from the "middle" of the pile.The cards moved are placed on top of whatever pile they are moved to.Only the top card may be removed from the main deck.Moves must be done following the rules of the game, which are as follows: Moving a card transfers one or more cards from either the main deck or a tableau pile to a tableau pile or a foundation pile. (Following the transfer of cards from the waste pile back to the main deck, they should appear in the order in which they originally occurred.) If the main deck is empty, then all of the cards are transferred from the waste pile back to the main deck. The new top card on the main deck is then exposed. (In Klondike, Aces are low.) There are four foundation piles, one for each suit.ĭrawing a card from the main deck means removing the current top card and placing it in a waste pile. Note that a tableau pile never contains a hidden card placed on top of an exposed card.Īt the beginning of the game, the first tableau pile has one card, the second has two cards, etc.Ī foundation pile contains cards of the same suit, arranged in order from Ace at the bottom of the pile to King at the top of the pile. A tableau pile may have more than one exposed card. If a tableau pile is non-empty, then it has at least one exposed card on the top of the pile. the main deck, which is a pile of cards with the top card turned overĪ tableau pile consists of 0 or more hidden cards at the bottom of the pile.Do not wait until the last minute to start it! Rules of the game You are welcome to use the Main.java from the solution as a starting point for your program, but you are not required to.Īlso, see the transcript of the game (with user input in bold). Note that this solution has no source code other than Main.java, the class containing the main method. You can import my solution into Eclipse in order to see how the game should work: You may be familiar with the game from the classic Windows game "Solitaire". Your task is to implement the card game called Klondike. When the program completes, right click on the project ( CS201_Assign04) and choose Refresh. In the console window, type yes when prompted. Right click on StartAssignment.java and choose Run As→Java Application. This assignment will use your code from Lab 10 as a starting point.ĭownload CS201_Assign04.zip and import it into your Eclipse workspace ( File→Import→General→Existing projects into workspace→Archive file.) You should see a project called CS201_Assign04 in the Package Explorer. Milestone 2 due Tuesday, July 15th Getting Started
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |