1 of 4
CSE 143, Winter 2010
Programming Assignment #4: Assassin (20 points)
Due Thursday, February 4, 2010, 11:30 PM
This program focuses on implementing a linked list.
Turn in a file named
Homework section of the course web site. You will need the support files
from the Homework section of the course web site; place them in the same folder as your class.
"Assassin" is a real-life game often played on college campuses. Each person playing has a particular target that he/she is
trying to "assassinate."
Generally "assassinating" a person means finding them on campus in public and acting on them in
some way, such as saying, "You're dead," or squirting them with a water gun, or touching them.
One of the things that
makes the game more interesting to play in real life is that initially each person knows only who they are assassinating;
they don't know who is trying to assassinate them, nor do they know whom the other people are trying to assassinate.
The game of assassin is played as follows: You start out with a group of people who want to play the game.
let's say that there are five people playing named Carol, Chris, Jim, Joe, Sally.
A circular chain of assassination targets
(called the "kill ring" in this program) is randomly established.
For example, we might decide Joe should stalk Sally,
Sally should stalk Jim, Jim should stalk Carol, Carol should stalk Chris, and Chris should stalk Joe.
(In the actual linked
list that implements this kill ring, Chris's
reference would be
But conceptually we can think of it as though
the next person after Chris is Joe, the front person in the list.)
Here is a picture of this "kill ring":
When someone is assassinated, the links need to be changed to "skip" that person.
For example, suppose that Jim is
assassinated by Sally.
Sally needs a new target, so we give her Jim's target: Carol.
The kill ring becomes:
If the first person in the kill ring is assassinated, the front of the list must adjust.
If Chris kills Joe, the list becomes:
You will write a class
that keeps track of who is stalking whom and the history of who killed whom.
You will maintain two linked lists: a list of people currently alive (the "kill ring") and a list of those who are dead (the
As people are killed, you will move them from the kill ring to the graveyard by rearranging links between
The game ends when only one node remains in the kill ring, representing the winner.
A client program has been written for you called
It reads a file of names, shuffles the names, and
constructs an object of your class
This main program then asks the user for the names of each
victim to kill until there is just one player left alive (at which point the game is over and the last remaining player wins).