Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data-Structures language java 1. Problem Description: In the children's game, Duck, Duck, Goose, a group of children sit in a circle. One of them is

image text in transcribed

image text in transcribed

image text in transcribed

Data-Structures

language java

1. Problem Description: In the children's game, Duck, Duck, Goose, a group of children sit in a circle. One of them is elected "it" and that person walks around the outside of the circle. The person who is "it" pats each child on the head, saying "Duck" each time, until randomly reaching a child that the "it" person identifies as "Goose." At this point there is a mad scramble, as the "Goose" and the "it" person race around the circle. Whoever returns to the Goose's former place first gets to remain in the circle. The loser of this race has to leave the game next round of play. The game continues like this until one child stays in the circle. Write software that simulates the game of Duck, Duck, Goose. 1.1 Requirements: You should have at least two classes: your data structure class and the game simulator class. You have to choose the best Linked-list to represent the players in the game (SLL, CLL, DLL). Your code should not have a time complexity higher than O(n?). You are required to log the time of the simulation. Your code should work with special cases. 1.2 Game implementation details: The elected "it" in the game should be chosen randomly for every round. When "it" goes around the circle, he/she can pat the same player with DUCK up two times (see the sample output). Which means, if you have 4 players in the circle, then "it" can go around the circle up to 2 times. "it" should at least pat one player with DUCK before choosing a player to be GOOSE. Goose should be chosen randomly. You should randomly decide who win the race between "it" and Goose. When a player is selected as "it", he/she should start with the player sitting next to him/her. For example, if player 5 was selected as "it", then "it" should start to pat player 6, then 7, etc. The player who wins the race ("it" or Goose), should sit back in the location of the goose. 1.3 Sample output: The game has initialized with 18 players Player 4 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK DUCK GOOSE players player06 player07 players player89 playerle playeroi playero2 Player 2 was picked as goose RUN! player 2 won and back in the game, player 4 should leave the game Current players in the game: player2 player3 players player player7 players player9 playerle playeri Player 5 was elected as "it" DUCK GOOSE player 6 player Player 7 was picked as goose RUN! player 7 won and back in the game, player 5 should leave the game Current players in the game: player players players playerle playeri player2 player3 player Player 8 was elected as "it" DUCK DUCK GOOSE player09 player10 player01 Player 1 was picked as goose RUN! player 1 won and back in the game, player 8 should leave the game Current players in the game: playeri player2 player3 player player7 players playerle DUCK DUCK Player 6 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK DUCK GOOSE player7 player09 player10 playeroi player02 player83 player7 player89 playerle player1 Player 1 was picked as goose RUN! "itwon, player 6 is back in the game, player 1 should leave the game Current players in the gane: player player2 players player7 player player10 Player 9 was elected as "it" DUCK DUCK DUCK DUCK DUCK GOOSE playeria player player2 playere3 playere7 playerle Player 10 was picked as goose RUN! player 18 won and back in the game, player 9 should leave the game Current players in the game: player10 player player2 player3 player? Player 2 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK player 3 playere7 playerle player86 playere3 player7 player10 GOOSE Player 10 was picked as goose RUN! player 18 won and back in the game, player 2 should leave the game Current players in the game! player10 player player3 player? Player 3 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK DUCK DUCK GOOSE playere7 playerle player player player1e player playere7 player1e player Player 6 was picked as goose RUN! player 6 won and back in the game, player 3 should leave the game Current players in the game! player player7 player10 Player 6 was elected as "it" DUCK DUCK GOOSE player07 player10 playera? Player 7 was picked as goose RUN! player 7 won and back in the game, player 6 should leave the game Current players in the game: player7 player10 Player 7 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK GOOSE player1e player10 playerle player10 player10 playerle player10 Player 10 was picked as goose RUN! "it" won, player 7 is back in the game, player 10 should leave the game Current players in the game player7 Player 7 won the game! The simulator spent 305 ms 1. Problem Description: In the children's game, Duck, Duck, Goose, a group of children sit in a circle. One of them is elected "it" and that person walks around the outside of the circle. The person who is "it" pats each child on the head, saying "Duck" each time, until randomly reaching a child that the "it" person identifies as "Goose." At this point there is a mad scramble, as the "Goose" and the "it" person race around the circle. Whoever returns to the Goose's former place first gets to remain in the circle. The loser of this race has to leave the game next round of play. The game continues like this until one child stays in the circle. Write software that simulates the game of Duck, Duck, Goose. 1.1 Requirements: You should have at least two classes: your data structure class and the game simulator class. You have to choose the best Linked-list to represent the players in the game (SLL, CLL, DLL). Your code should not have a time complexity higher than O(n?). You are required to log the time of the simulation. Your code should work with special cases. 1.2 Game implementation details: The elected "it" in the game should be chosen randomly for every round. When "it" goes around the circle, he/she can pat the same player with DUCK up two times (see the sample output). Which means, if you have 4 players in the circle, then "it" can go around the circle up to 2 times. "it" should at least pat one player with DUCK before choosing a player to be GOOSE. Goose should be chosen randomly. You should randomly decide who win the race between "it" and Goose. When a player is selected as "it", he/she should start with the player sitting next to him/her. For example, if player 5 was selected as "it", then "it" should start to pat player 6, then 7, etc. The player who wins the race ("it" or Goose), should sit back in the location of the goose. 1.3 Sample output: The game has initialized with 18 players Player 4 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK DUCK GOOSE players player06 player07 players player89 playerle playeroi playero2 Player 2 was picked as goose RUN! player 2 won and back in the game, player 4 should leave the game Current players in the game: player2 player3 players player player7 players player9 playerle playeri Player 5 was elected as "it" DUCK GOOSE player 6 player Player 7 was picked as goose RUN! player 7 won and back in the game, player 5 should leave the game Current players in the game: player players players playerle playeri player2 player3 player Player 8 was elected as "it" DUCK DUCK GOOSE player09 player10 player01 Player 1 was picked as goose RUN! player 1 won and back in the game, player 8 should leave the game Current players in the game: playeri player2 player3 player player7 players playerle DUCK DUCK Player 6 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK DUCK GOOSE player7 player09 player10 playeroi player02 player83 player7 player89 playerle player1 Player 1 was picked as goose RUN! "itwon, player 6 is back in the game, player 1 should leave the game Current players in the gane: player player2 players player7 player player10 Player 9 was elected as "it" DUCK DUCK DUCK DUCK DUCK GOOSE playeria player player2 playere3 playere7 playerle Player 10 was picked as goose RUN! player 18 won and back in the game, player 9 should leave the game Current players in the game: player10 player player2 player3 player? Player 2 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK player 3 playere7 playerle player86 playere3 player7 player10 GOOSE Player 10 was picked as goose RUN! player 18 won and back in the game, player 2 should leave the game Current players in the game! player10 player player3 player? Player 3 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK DUCK DUCK GOOSE playere7 playerle player player player1e player playere7 player1e player Player 6 was picked as goose RUN! player 6 won and back in the game, player 3 should leave the game Current players in the game! player player7 player10 Player 6 was elected as "it" DUCK DUCK GOOSE player07 player10 playera? Player 7 was picked as goose RUN! player 7 won and back in the game, player 6 should leave the game Current players in the game: player7 player10 Player 7 was elected as "it" DUCK DUCK DUCK DUCK DUCK DUCK GOOSE player1e player10 playerle player10 player10 playerle player10 Player 10 was picked as goose RUN! "it" won, player 7 is back in the game, player 10 should leave the game Current players in the game player7 Player 7 won the game! The simulator spent 305 ms

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

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions