Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solitaire In this midterm you are to create a variation of the popular card game SOLITAIRE using stacks and queues. Here is a picture of

image text in transcribed

Solitaire In this midterm you are to create a variation of the popular card game SOLITAIRE using stacks and queues. Here is a picture of the layout of the game. You can play the online version by clicking here. Game terms and design requirements are explained right after the image. Tableau (7 queues and 7 stacks) Deck/Stock (slack) Waste (stack) Foundation (4 stacks) UNDO NEW Deck/Stock - A pile of cards, face down, which are left over after setting up the other layout areas. These are turned over one at a time into the waste. For your program this pile of cards MUST be stored in a STACK Waste - The area where the cards from the deck/stock go when they are brought into play. Only cards from the stock can be played to the waste. Only the topmost card can be moved to either the foundation or to the tableau. For your program this pile of cards MUST be stored in a STACK Foundations. The aim of the games is to clear the tableau and move all the cards to the foundation. They are built up by suit from Acelt) to King(13). Assume at the start of the game, the four ACEs are already placed on the foundation. For your program this pile of cards MUST be stored in four separate STACKS. (one for each suit). Recommended you use an ARRAY of Stacks for this. Tableaus. This consists of a number of piles where cards can be moved from one tableau to another or from tableau to a foundation. For your program this pile of cards MUST be stored in 7 STACKS and 7 QUEUES. Cach tableau (ex. T4 see picture) has both a slack and a queue. The stack holds the cards that have been turned over while the queue holds the cards that have not yet turned. Al the start of the game Tableau 0 (TO See picture) starts with a queue containing 1 card, T1 has two cards, T2 has 3 cards and so on. The game begins by DCQUEUING One card from each of these queues and placing it into the stack of the tableau. Hence, the TO queue begins the game with cards, T1 queue has 1 card and so forth while each of the tableau stacks have the one card to start with the topmost card you can see). Recommended you use an ARRAY of 7 queues and another ARRAY of 7 stacks for this Creating a shuffled deck of 52 cards Your deck of cards should be represented by a number (1-13) followed by the first letter of the suit. Example: 1H, 5S, 120, 13D would mean ace of hearts(1H), 5 of Spades(55), queen of clubs(120 and king of diamonds(13D). The deck also needs to be shuffled. To get you started I have provided sample code you can begin with that generales 52 cards into a shullied ArrayList (click here). You MUST put the elements of this ArrayListinto your deck Slack yourself. Stacks and Queues You may use Java's ArrayDeque class and Java's Slack class or you may use your own SlackBox / QueueBox code or any combination of these four BUT your solution must use stacks and queues as described above. *** Assume for all Slacks you can only move and see (peek) the top card of any stack. Sample Program Download my program (executable only, unzip, and run runme.bal (click here). Replicate my program's look and behavior. Do not try to "decompile" this program. There are safeguards in place and detection of cheating will result in disciplinary action. Simple Game Rules You can only move the top card of any stack. To move a card to the foundation, the foundation must have the previous card already there. Example, you can't move 12D il 11D is not already in the foundation. To move a card onto a tableau, the card must be one less than the card currently showing on the largel Lableau AND the suit color must be opposite color than the card showing. Example, moving 7H on a tableau currently showing a as is allowed but you can't move 7H to a 8D (Suil colors are both red). You can also move any card to the tableau if the tableau is empty (no cards in its stack or queue left). Marking & Grading IMPORTANT. Your program must use stacks and queues as described. If you don't use (mostly stacks and queues then madimum mark given will be 25% even if the program does work [10 marks]: Program uses Slacks and Queues for deck, waste, Lableaus, and foundations 12 marks]: Draw a card from deck stack to waste slack. [2 marks: Move all cards from waste stack back to desk stack when deck slack is empty (4 marks: Move waste card to foundations correctly assuming move is allowed. [4 marks: Move waste card to a tableau assuming move is allowed 16 marks: Moving a tableau card from one tableau to another assuming move is allowed [4 marks: Dequeing a tableau queue and placing Card on the tableau Slack when slack is empty. [4 marks: Moving tableau card to foundations assuming move is allowed. [4 marks): Game robustness testing ( can't crash the program) Solitaire In this midterm you are to create a variation of the popular card game SOLITAIRE using stacks and queues. Here is a picture of the layout of the game. You can play the online version by clicking here. Game terms and design requirements are explained right after the image. Tableau (7 queues and 7 stacks) Deck/Stock (slack) Waste (stack) Foundation (4 stacks) UNDO NEW Deck/Stock - A pile of cards, face down, which are left over after setting up the other layout areas. These are turned over one at a time into the waste. For your program this pile of cards MUST be stored in a STACK Waste - The area where the cards from the deck/stock go when they are brought into play. Only cards from the stock can be played to the waste. Only the topmost card can be moved to either the foundation or to the tableau. For your program this pile of cards MUST be stored in a STACK Foundations. The aim of the games is to clear the tableau and move all the cards to the foundation. They are built up by suit from Acelt) to King(13). Assume at the start of the game, the four ACEs are already placed on the foundation. For your program this pile of cards MUST be stored in four separate STACKS. (one for each suit). Recommended you use an ARRAY of Stacks for this. Tableaus. This consists of a number of piles where cards can be moved from one tableau to another or from tableau to a foundation. For your program this pile of cards MUST be stored in 7 STACKS and 7 QUEUES. Cach tableau (ex. T4 see picture) has both a slack and a queue. The stack holds the cards that have been turned over while the queue holds the cards that have not yet turned. Al the start of the game Tableau 0 (TO See picture) starts with a queue containing 1 card, T1 has two cards, T2 has 3 cards and so on. The game begins by DCQUEUING One card from each of these queues and placing it into the stack of the tableau. Hence, the TO queue begins the game with cards, T1 queue has 1 card and so forth while each of the tableau stacks have the one card to start with the topmost card you can see). Recommended you use an ARRAY of 7 queues and another ARRAY of 7 stacks for this Creating a shuffled deck of 52 cards Your deck of cards should be represented by a number (1-13) followed by the first letter of the suit. Example: 1H, 5S, 120, 13D would mean ace of hearts(1H), 5 of Spades(55), queen of clubs(120 and king of diamonds(13D). The deck also needs to be shuffled. To get you started I have provided sample code you can begin with that generales 52 cards into a shullied ArrayList (click here). You MUST put the elements of this ArrayListinto your deck Slack yourself. Stacks and Queues You may use Java's ArrayDeque class and Java's Slack class or you may use your own SlackBox / QueueBox code or any combination of these four BUT your solution must use stacks and queues as described above. *** Assume for all Slacks you can only move and see (peek) the top card of any stack. Sample Program Download my program (executable only, unzip, and run runme.bal (click here). Replicate my program's look and behavior. Do not try to "decompile" this program. There are safeguards in place and detection of cheating will result in disciplinary action. Simple Game Rules You can only move the top card of any stack. To move a card to the foundation, the foundation must have the previous card already there. Example, you can't move 12D il 11D is not already in the foundation. To move a card onto a tableau, the card must be one less than the card currently showing on the largel Lableau AND the suit color must be opposite color than the card showing. Example, moving 7H on a tableau currently showing a as is allowed but you can't move 7H to a 8D (Suil colors are both red). You can also move any card to the tableau if the tableau is empty (no cards in its stack or queue left). Marking & Grading IMPORTANT. Your program must use stacks and queues as described. If you don't use (mostly stacks and queues then madimum mark given will be 25% even if the program does work [10 marks]: Program uses Slacks and Queues for deck, waste, Lableaus, and foundations 12 marks]: Draw a card from deck stack to waste slack. [2 marks: Move all cards from waste stack back to desk stack when deck slack is empty (4 marks: Move waste card to foundations correctly assuming move is allowed. [4 marks: Move waste card to a tableau assuming move is allowed 16 marks: Moving a tableau card from one tableau to another assuming move is allowed [4 marks: Dequeing a tableau queue and placing Card on the tableau Slack when slack is empty. [4 marks: Moving tableau card to foundations assuming move is allowed. [4 marks): Game robustness testing ( can't crash the program)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions

Question

Define Decision making

Answered: 1 week ago

Question

What are the major social responsibilities of business managers ?

Answered: 1 week ago

Question

What are the skills of management ?

Answered: 1 week ago

Question

1. Explain how business strategy affects HR strategy.

Answered: 1 week ago