Duck, Duck, Goose We are going to play duck, duck, goose. Read the text file of unique first names (players.txt) and place them in a
Duck, Duck, Goose
- We are going to play duck, duck, goose. Read the text file of unique first names (players.txt) and place them in a circular linked list. Assume the text file is properly formatted and that there is no bad data. Assume text file is in the current directory.
- Print the circular linked list in a serial format to the console. The assumption is that the head of the list will be linked to the tail of the list.
- Generate a random number between 1 and 10 inclusive. This number is the player who is the goose. Output this random number to the console.
- Iterate over the linked list. Remove the goose (a loser) from the circular linked list. Print the new circular linked list in a serial format. The assumption is that the head of the list will be linked to the tail of the list.
- Generate another random number between 1 and 10 inclusive. This is the new goose. Starting at the player AFTER the last loser, find the next goose. Print the new circular linked list in a serial format after this goose is removed.
- Continue play until there is only one player left in the listThe WINNER!! Print out the winner.
- Name your primary class which contains your main method DuckDuckGoose.java.
- Submit all java files needed to build and run your application. Do not use packages, as this makes grading more difficult.
- You must use the LinkedList class with an iterator. NO INDEXING MAY BE USED! Any additional instructions given in class must be conformed to.
Here is my code. The problem is that it leaves couple of names. It is supposed to leave one name left as the winner.
There are 19 names.
http://collabedit.com/q248e
import java.io.*; import java.util.*; import java.util.Scanner; import java.util.Iterator; import java.util.LinkedList; import java.util.Random;
public class DuckDuckGoose {
public static void main(String[] args) { LinkedList
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started