Amend lab5.cpp so that it
prompts the user for new data. The query and response
should be as indicated below.
Enter 'P' new player, 'S' new or existing score for a player, or 'X' exit?
<user enters 'w'>
Enter 'P' or 'S' or 'X':
<user enters either 'P' or 'p'>
Enter new player's username:
<user enters "funnygrl">
funnygrl is a new player, all scores are 0.
Enter 'P' new player, 'S' new or existing score for a player, or 'X' exit?
<user enters 'S' or 's'>
Enter player's username:
<user enters "ObiWan">
Player Obiwan does not exist.
Enter 'P' new player, 'S' new or existing score for a player, or 'X' exit?
<user enters 'S' or 's'>
Enter player's username:
<user enters "funnygrl">
Enter level:
<user enters an integer between 1 and 4, say it is 2>
Enter new Level 2 score for funnygrl (0 for score report):
<user enters an integer between 0 and INT_MAX, say it is 300>
300 is a new high score for funnygrl at level 2! Recorded.
Enter 'P' new player, 'S' new or existing score for a player, or 'X' exit?
<user enters 'S' or 's'>
Enter player's username:
<user enters "funnygrl">
Enter level:
<user enters an integer between 1 and 4, say it is 2>
Enter new Level 2 score for funnygrl (0 for score report):
<user enters an integer between 0 and INT_MAX, say it is 200>
funnygrl has score of 300 at level 2.
Enter 'P' new player, 'S' for new or existing score for a player, or 'X' exit?
<user enters either 'P' or 'p'>
Enter new player's username:
<user enters "funnygrl">
funnygrl already exists.
Enter 'P' new player, 'S' for new or existing score for a player, or 'X' exit?
<user enters 'X' or 'x'>
Thanks for playing!
As usual, however, do not put a newline in between
the program's prompt and the user's input. Look
here for what that
same interaction would look like on the screen.
At the point of 'X' or exit, the program will write the current
set of data to the file game.dat. It should
overwrite the existing file. All player data records
should be lines that start with the letter 'P'.
The final line should start with 'Z' to indicate
end of data.
When the program starts up again, any new data (new players
or new scores) should be reflected in the new outputs, when
queried. (I.e., funnygrls score at level 2 should be 300.)
Also, if there is no game.dat file in the
current directory, at the beginning of the program's
execution the program should say, "No game.dat
file found, creating one..." and should proceed to
the input sequence as given above.
Note that if any score is entered that is less than
the player's current score at that level, then
the program gives a report of the player's current
score at that level.