ArrayList THE CLASS: H

advertisement
THE ArrayList CLASS:
HALO PARTY INVITATION PROGRAM
You’ve decided to host a Halo Party but it turns out that the number of
people who accepted your invitation exceeds the number of people you’re
allowed to have at your house. So you need to cut the guest list down to the
number your parents will allow. In order to cut the list down, you are going
to use what you believe to be the most fair and unbiased way of uninviting
people from the guest list.
When the program starts, you’re going to need to enter the number of
guests that were initially invited to your party, followed by the maximum
number of people that you are allowed to have.
In the following example, 50 guests were invited and only a maximum of 20
people are allowed to the party:
The way the guest list is going to be determined is by first assigning a number from 1 to the number of
guests invited to each guest who accepted your invitation. So if I invited 50 guests, each guest is going
The ArrayList Class
Page 1 of 3
to be assigned a number from 1-50. The assigned numbers should be stored in an ArrayList of Integer
objects.
When the user clicks START, the guest list should be outputted in the JTextArea with the numbers
assigned to each guest:
The process of elimination exists by removing every 2nd person from the ArrayList, followed by removing
every 3rd person, then every 4th person, etc. This keeps going until the desired number of guests is
reached.
Be sure to output the updated guest list after each round of eliminations. Also, be sure to use a Timer so
that the elimination process does not happen all at once. Use an interval of 500-1000 seconds for each
round of eliminations.
Once you reach the desired number of guests, be sure to stop the Timer and output the total number of
guests.
Your output should look something like this:
The ArrayList Class
Page 2 of 3
Save the project as Halo Party in your UNIT 4 folder.
The ArrayList Class
Page 3 of 3
Download