Write a simulation of a game. The game itself is not important. What is important is that the player sit at a large circular table and take turns sequentially in a clockwise direction. Also important is that any player can leave the game at anytime and that new players can join the game at any time. When a new player joins the game he/she always sits in the position in the circle will make him/her the next player to take a turn. However he/she may not be the next player to take a turn. (Can you figure out under what circumstances he/she might not be the next one to take a turn?) There can be anywhere between 0 and 20 players at any give time. The system must support the following commands:
When executing the REMOVE command and there are more than one players with the specified name then the one who will have his/her turn first will be the only one to be removed.
When the PLAY command is executed and the next player to take a turn is named Joe, the system will display the following line on the screen:
Joe takes a turn.
If the PLAY command is executed again the player after Joe will take their turn.
Assume that there are four players in the game. Joe is the one who will take the next turn followed by Sally, Jim and Becky.
When the PLAYROUND command is executed the following lines will be displayed on the screen:
Joe takes a turn.
Sally takes a turn.
Jim takes a turn.
Becky takes a turn.
At the end of the PLAYROUND command it will be Joe's turn again.
The program must include at least three classes Game, CircleList and Player.
The program must be implemented twice. In the first implementation the CircleList class will be implemented using an array of players. In the second implementation the CircleList class will be implemented as circular linked list. You will submit two seperate and complete HW's with each implementation.
The Game class that will contain all the functionality of the program.
It will have a transduser function that will input a string and output a string.
The Game class will have no I/O in it.
There will be a simple command interface function that will use the Game transducer function and do all of the I/O.
Both implementations of the CircleList class will have the same public sections (the same user interface). The main.cpp will be esentially the same for both programs.
The QUIT command causes the program to stop executing. Before it stops executing it will remove all players from the game.
One of the ways that some students may lose points on accuracy is when inserting new players before the last inserted player gets a turn. Lets review this in detail. When a player is added to an empty list it is considered to be the last player to have played.
If the list is empty and player X is added then player X will be considered to be the last player to have played.
When player Y is added he or she be placed after X so that it will be the next player to take a turn. This is all according to the rules described above. Now if player Z is added before any players have taken a turn then player Z will be added right after player X(which is considered to the last player to have taken a turn). NOw player Z will be the next player to take a turn.
Now if the PLAYROUND command is executed the following will be generated:
Z takes a turn.
Y takes a turn.
X takes a turn.
Another example of this is given here:
ADD A
ADD B
ADD C
ADD D
PLAYROUND
D takes a turn.
C takes a turn.
B takes a turn.
A takes a turn.
REMOVE B
PLAYROUND
D takes a turn.
C takes a turn.
A takes a turn.
PLAY
D takes a turn.