{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


extraExercisesMarch3108 - Randomly pick a pigeon go through...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP202 Instructor: Ladan Mahabadi March 31, 2008 Write a class FileIO that upon executing the following command: java FileIO one two three four types in 1: one 2: two 3: three 4: four Write your program so that it works for any in-line argument entry (i.e. the choices of one, two, three, four are arbitrary)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Pigeons and a Bucket Imagine you see a flock of pigeons on the ground swarming around a bucket of seed. Write a program that simulates survival of fittest as follows: Your program should ask the user for the number of pigeons If the number is less than five then prompt the user for pigeons‘ information, and other wise randomly generate. Pigeons have Names (strings between 1 and num) Strength values (a double between 1 and 10) Position (a Point between on the 10 X 10 grid) Distance (a double value indicating each pigeon’s distance to the bucket) And they share a bucket that is represented as a point Your program should simulate the struggle between the pigeons as follows:
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Randomly pick a pigeon, go through the array list (called flock) that contains all pigeons, and find the first occurrence of a pigeon with a smaller strength that is closer to the bucket. If such a pigeon is found, remove that pigeon and move your first pigeon to that position. Continue this process until one of the pigeons reaches the bucket (i.e. distance becomes zero) Display the surviving flock information (i.e. name, position) Ladan Mahabadi Today, 10:50 AM Added Text Ladan Mahabadi Today, 10:48 AM Deleted: Tab Pigeons and Files: Your program should retrieve the number of pigeons, and their information from a file called “pigeon.txt”. The first line in the file will be the number, followed by the information about the pigeons (each line corresponds to one pigeon). Go through the calculations as above, and then write the information of the surviving flock to a new file called “remainingPigeons.txt”....
View Full Document

{[ snackBarMessage ]}

Page1 / 3

extraExercisesMarch3108 - Randomly pick a pigeon go through...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online