In a new on-line game called "City of Assassins", we're going to
insert characters (assassins) and give them missions. Instead of
going after the usual kind of victim, we're going to send each
assassin after another assassin. In fact, we will create N
assassins and ask Assassin 0 to terminate Assassin 1. In turn,
Assassin i will be asked to terminate Assassin i+1.
Finally, Assassin N-1 will be asked to go after
Assassin 0.
As makers of the game, we will place all the assassins in a
circular linked-list that you will implement.
The code is very similar to that of a linked list, with
one exception: the last element points to the first element.
Thus, you will create a class called CircularList
more or less like the linked-list we've seen in class.
For the purpose of the game, you will implement one more
method: fire():
- The method fire (String assassin) takes in
an Assassin's name, finds the assassin in the circle.
Then, this assassin fires, eliminating the person "next" in line.
Thus, you will remove the element next to the named assassin.
- You will accomplish the removal by appropriate manipulation
of pointers.
To get started:
- Download and modify AssassinGame.java.
Write all your code in this file.
- You should be able to use much of the code written for
linked-lists that we covered in class.
- Read through main() and work out by hand the contents
of list before and after each time fire() is called.
- You must make sure that every next pointer points
to something. It can't point to null (else it wouldn't
be a circular list).
How the assignment is graded:
- Implementation of method add(): 15%
- Implementation of method size(): 15%
- Implementation of method toString(): 15%
- Implementation of method fire(): 15%
- Proper output of program: 20%
- Style and readability: 20%
Submission:
What else is due: