Computer Science 160
Spring 2006
Lab 5
Linked Lists – Taking Turns
This lab is due at the beginning of the lab February 22, 2004.
(Page 287--8 from "Data Abstraction & Problem Solving with Java")
When you play a board or card game or when you use a shared computing resource, you get a turn and then wait until everyone else has had a turn. Although the number of players in a game remains relatively static, the number of users of a shared computing service fluctuates. Let’s assume that this fluctuation will occur.
Design an ADT that keeps track of turns within a group of people. You should be able to add or delete people and determine whose turn occurs now.
Begin with a given group of people; assign these people an initial order. (This order can be random or specified by the user.) The first new person joining the group should get a turn after all others have had an equal number of turns. Each subsequent new person should get a turn after the person who joined the group most recently has a turn.
Also design an ADT to represent a person. (You can be conservative with the amount of data that this ADT contains.) The data elements that your first ADT stores are instances of the ADT person.
Implement your ADTs as Java classes. Use a circular linked list as the data structure that keeps track of turns. Implement this linked list by using references and not by using any other class.
Write a program that uses and, therefore, tests your ADTs completely. Your program should process several insertion and deletion operations and should demonstrate that people are given turns correctly.
Demonstrate your program to either the instructor or lab assistant. Take a screen shot of the successful demo screen. Hand in your lab report which should contain the screen shot of the successful demo.