Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me solve this coding assignment. Thanks! Edit1: Code has to be in java. Edit2: Please make use/solve using Decision, Loops and 2D arrays,

Please help me solve this coding assignment. Thanks!

Edit1: Code has to be in java.

Edit2: Please make use/solve using Decision, Loops and 2D arrays, thanks!image text in transcribedimage text in transcribedimage text in transcribed

PROBLEM 1: Match-making [50points) For the first portion of this problem, you will implement a simple version of our game Ochos Lacos. For this simplified version, there will be three players. The rules of the game are as follows: Basic Rules of the game Ochos Locos Setup: The game starts with a shuffled deck of 32 cards (given to you). Each player is dealt 5 cards and one card is upturned in the discard pile. The remaining cards from the deck are placed in a draw pile Play On a player's tum, they must play a card (if one exists) that matches either the colour or number of the card played just before: o If the player has more cards in their hand of the matching number than they do of the matching colour: They will choose to play a cord of matching number. (e.g.4) They will play the card of that number that they have which comes first in rainbow order: red-yellow-green-blue. (i.e. R4-Y4-G4-B4) o If the player equal or more cards in their hand of the matching colour than they do of the matching number: They will choose to play a card of matching colour. They will play the card of that colour that they have which comes first counting order. 1-2-3-4-5-6-7-8. If a player does not have a card that they are able to play, they pick up a new card from the top of the draw ple lif one exists, pass if rot). Example 1 (more cards of matching number): Suppose the upturned card in the discard pile is a Green 3 (G3) ard that the player's hand has the following cards in it: R3 R7 Y3 Y7 G8 B3 B7 B8 The player will look at their hand and count the number of red cards (2 red cards: R3 & R7) and the number of 3 (three: R3. Y3 & B3). . Since they have more threes than red cards, they will choose to play a three card, but which coloure They have a red, yellow and blue 3, so they choose to play the red because it comes first in rainbow order fred-yellow-green-blue), choosing first red then yellow, then green and lastly blue, The player will choose to play the card R3. Input Hand of player one initially 5 cards) Hand of player two (initially 5 cards) Hand of player three initially 5 cards) First card in the discard pie on which to you play on 11 card) Remaining cards in the draw pile top to bottom, all remaining cards) Processing 1. Output the starting card on the discard pile. 2. Storting with player one, decide which card they will play (or pick up from the draw ple and output their choice (or Draw if they have no match and must try to pick up a card from the draw pile). 3. Repeat this for each player until a player has no more cards in their hand. This player becomes the winner of the game. Example 2 (eqval or more cards of matching colour): Suppose this time the upturned card in the discard pile is a Blue-8 (B8) and that the player's hand is the same as before with the following cards in it: R3 R7 Y3 Y7 GB B7 BB The player will look at their hand and count the number of blue cards 13 blue cards: B7 & 881 and the number of es two eights: G8 & B-8). Since they have at least as many blue cards as eights, they will choose to play a blue card, but which nurnber? They have a blue 7 and a blue 8. Since 7 comes before 8 in counting order, they will choose to play the 7. The player will choose to play the card B7. Output format 0: First/starting card on the discord pile) 1: (Card played by player 1") 2Card played by player 2) 3: {Cord played by player 3) 1: {Cord played by player 1"} 2: (Card played by player 2} 3: Cord played by player 3) Example 3 (no match in hand): Suppose this time the upturned card in the ciscard pile is a Yellow 4 144and that the player's hand has the following cards in it: R1 R2 G3 G5 B6 B7 B8 The player has no cards that match they Yellow-4 in either colour or number i.e. they have no cards they are either yellow or the number 4). They must DRAW a card from the draw pile. {N}: {Last card played by player N} (WINNER) Where N = 1.2. or 3. the player first able to play all of their cards and emoty their hand *If no card is able to be played by a player, output DRAW on their turn and pick from the craw pile (if one exists). Page 2 of 4 Sample input Sample output New hand after play Y3 Y7 Y! Bl 87 R8 Yi G4 G8 BB R3 R4 R7 Y6 D5 0: 83 1: B1 B7 1: Y3 Y7 YB B 2: RB 3: R3 1: Y3 R2 65 B6 Y5 G2 YA RI GI Y2 G6 B4 R5 G7 R6 B2 1: Y3 3: R3 1: Y3 2. R2 RB 4 G4 GB 3: R3 R4 *6 1: 1 Y8 2: R2 R8 G4 G5 G8 3: A R4 1! YB 2: 2 R8 G4 G5 GB 2: DRAK 3: R3 1: DRAK 2: R2 3: R4 (WINNER) R1 R4 G2 G8 B2 R2 R3 YZ YB B3 R3 R6 Y3 G4 G5 B6 Y2 B7 Yl G6 Y5 G7 ... R5 R7 G1 Y4 B5 G3 B1 D D4 76 1: R1 R4 G2 G8 82 2: R2 RB YT YB - 3: A R6 1: A R4 2: R2 R8 3: RG Y3 G4 G5 1: A4 G2 GB 2: Ho Y7 YB 3: 12 Y3 C4 C5 1: G2 e 2: 77 10 3: # Y3 G4 G5 1: 62 3: DRAK 1: G8 2: Y 3: Y2 1: G2 (WINNER) Note: In the "New hand efter play" column, cards are shown for fun!in their colour. An underlined card le... B7) was just added to the player's hand and a card with a strikethrough le.ge was just ployed from the player's hand. I have made bod le.g v2 any craw pile cards that were used. PROBLEM 1: Match-making [50points) For the first portion of this problem, you will implement a simple version of our game Ochos Lacos. For this simplified version, there will be three players. The rules of the game are as follows: Basic Rules of the game Ochos Locos Setup: The game starts with a shuffled deck of 32 cards (given to you). Each player is dealt 5 cards and one card is upturned in the discard pile. The remaining cards from the deck are placed in a draw pile Play On a player's tum, they must play a card (if one exists) that matches either the colour or number of the card played just before: o If the player has more cards in their hand of the matching number than they do of the matching colour: They will choose to play a cord of matching number. (e.g.4) They will play the card of that number that they have which comes first in rainbow order: red-yellow-green-blue. (i.e. R4-Y4-G4-B4) o If the player equal or more cards in their hand of the matching colour than they do of the matching number: They will choose to play a card of matching colour. They will play the card of that colour that they have which comes first counting order. 1-2-3-4-5-6-7-8. If a player does not have a card that they are able to play, they pick up a new card from the top of the draw ple lif one exists, pass if rot). Example 1 (more cards of matching number): Suppose the upturned card in the discard pile is a Green 3 (G3) ard that the player's hand has the following cards in it: R3 R7 Y3 Y7 G8 B3 B7 B8 The player will look at their hand and count the number of red cards (2 red cards: R3 & R7) and the number of 3 (three: R3. Y3 & B3). . Since they have more threes than red cards, they will choose to play a three card, but which coloure They have a red, yellow and blue 3, so they choose to play the red because it comes first in rainbow order fred-yellow-green-blue), choosing first red then yellow, then green and lastly blue, The player will choose to play the card R3. Input Hand of player one initially 5 cards) Hand of player two (initially 5 cards) Hand of player three initially 5 cards) First card in the discard pie on which to you play on 11 card) Remaining cards in the draw pile top to bottom, all remaining cards) Processing 1. Output the starting card on the discard pile. 2. Storting with player one, decide which card they will play (or pick up from the draw ple and output their choice (or Draw if they have no match and must try to pick up a card from the draw pile). 3. Repeat this for each player until a player has no more cards in their hand. This player becomes the winner of the game. Example 2 (eqval or more cards of matching colour): Suppose this time the upturned card in the discard pile is a Blue-8 (B8) and that the player's hand is the same as before with the following cards in it: R3 R7 Y3 Y7 GB B7 BB The player will look at their hand and count the number of blue cards 13 blue cards: B7 & 881 and the number of es two eights: G8 & B-8). Since they have at least as many blue cards as eights, they will choose to play a blue card, but which nurnber? They have a blue 7 and a blue 8. Since 7 comes before 8 in counting order, they will choose to play the 7. The player will choose to play the card B7. Output format 0: First/starting card on the discord pile) 1: (Card played by player 1") 2Card played by player 2) 3: {Cord played by player 3) 1: {Cord played by player 1"} 2: (Card played by player 2} 3: Cord played by player 3) Example 3 (no match in hand): Suppose this time the upturned card in the ciscard pile is a Yellow 4 144and that the player's hand has the following cards in it: R1 R2 G3 G5 B6 B7 B8 The player has no cards that match they Yellow-4 in either colour or number i.e. they have no cards they are either yellow or the number 4). They must DRAW a card from the draw pile. {N}: {Last card played by player N} (WINNER) Where N = 1.2. or 3. the player first able to play all of their cards and emoty their hand *If no card is able to be played by a player, output DRAW on their turn and pick from the craw pile (if one exists). Page 2 of 4 Sample input Sample output New hand after play Y3 Y7 Y! Bl 87 R8 Yi G4 G8 BB R3 R4 R7 Y6 D5 0: 83 1: B1 B7 1: Y3 Y7 YB B 2: RB 3: R3 1: Y3 R2 65 B6 Y5 G2 YA RI GI Y2 G6 B4 R5 G7 R6 B2 1: Y3 3: R3 1: Y3 2. R2 RB 4 G4 GB 3: R3 R4 *6 1: 1 Y8 2: R2 R8 G4 G5 G8 3: A R4 1! YB 2: 2 R8 G4 G5 GB 2: DRAK 3: R3 1: DRAK 2: R2 3: R4 (WINNER) R1 R4 G2 G8 B2 R2 R3 YZ YB B3 R3 R6 Y3 G4 G5 B6 Y2 B7 Yl G6 Y5 G7 ... R5 R7 G1 Y4 B5 G3 B1 D D4 76 1: R1 R4 G2 G8 82 2: R2 RB YT YB - 3: A R6 1: A R4 2: R2 R8 3: RG Y3 G4 G5 1: A4 G2 GB 2: Ho Y7 YB 3: 12 Y3 C4 C5 1: G2 e 2: 77 10 3: # Y3 G4 G5 1: 62 3: DRAK 1: G8 2: Y 3: Y2 1: G2 (WINNER) Note: In the "New hand efter play" column, cards are shown for fun!in their colour. An underlined card le... B7) was just added to the player's hand and a card with a strikethrough le.ge was just ployed from the player's hand. I have made bod le.g v2 any craw pile cards that were used

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

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

Students also viewed these Databases questions

Question

Does it avoid use of underlining?

Answered: 1 week ago