CMPE 160 – INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING

 

PROJECT #3

 

Due: 06.08.2006 Sunday at 24:00

 

Who is Left Out

In this project, you are going to implement a simple game called “Who is left out”. Your program will read the input to the program from a text file in which the index of each player and an integer associated with him is written. The players are arranged in a circular pattern assumed to start with the first player specified with the right to act. At each turn, the player who has the right to act removes the player that is N players farther away in the forwrd direction and the right to act passes to the player that was 1 farther away from the elected player in the forward direction. At some instant, only one player remains in the line and she is the one who is left out. Your program must output the index of that player. Indices start with 1 in the input file and go on with one more for each new player.

The format for input files (It will be named “input.txt”.):

1 3         /* Player 1 removes 3 away */

2 5         /* Player 2 removes 5 away */

3 2         /* Player 3 removes 2 away */

4 6         /* Player 4 removes 6 away */

5 4         /* Player 5 removes 4 away */

The operation of your program must be like the following:

1) The program starts by reading the input file ("input.txt").

2) It outputs the index of the player that is left out.

For the above input file (input.txt), the output must be:

Player 2 is left out.

Project Notes

Implementation Details

 

 

NOTES: