Hey I really need help figuring out this problem for my program study group. I need to show this code in my presentation. I was just wondering if anyone could help me figue it out. Heres the problem.
Assume in all situations, the user enters valid input.
Many games store a player's score and allow the player to have multiple lives. The final score of playing a game is the score the player attains at the point in time that they have no lives left. Furthermore, many of these games have several rounds or boards. If a player completes a round without losing a life, rather than the opponent getting a chance to play, that player gets to continue playing. Using these general guidelines, you will design the framework for a game program without knowing any detailed information of the game. You will only be given the function prototype for a function that executes a single round of a game as well as some other specifications for how you should run the game.
the goal is to show how a good functional design can be used to split up work amongst mostly independently working programmers, an actual function will not be provided until after the due date to the assignment.
Here is the prototype of the function you will have to call that executes a single round of a game:
// Pre-condition: name is the name of the current player. numlives is a reference to
// the variable storing the number of lives left of the current player.
// score is a reference to the variable storing the score of the current
// player, and round is the round the player is currently on.
// Post-conditions: A single round of the game will be executed. The player's score
// and number of lives will be adjusted accordingly. The round
// will be completed unless the player has no more lives left.
void playround(char name, int* numlives, int* score, int round);
You will execute a competition between two players in this mystery game. Before the game starts, ask each player their name and set their scores to 0 and their total number of lives to 5.
After this, the game begins. Allow player 1 to go first. On a particular round, if a player does NOT lose any lives, then do NOT change the turn to the next player. Instead, allow the same player to continue their turn playing the next round.
In the situation that the player does lose at least one life, the subsequent turn is taken by the other player. The only exception to either of these rules is if one player has 0 lives. If one player has 0 lives, then all turns will be given to his/her competitor till they lose all their lives.
Your main goal will be to call the playround function when appropriate, control who's turn it is and quit the game and print out the final results of both players. You should print out a status report for each player after they finish a round. (Or if they do not succeed in finishing a round and end up with 0 lives while playing a round.)
Note: This setup is DIFFERENT than standard video games where your opponent always gets to go after you lose a life. Here the change in turn is indicated by finishing a round in which you could lose more than one life. Furthermore, if you finish a round without losing a life, the turn doesn't change, but you DO have to make a new call to the playround function. It is also possible for you to finish a round, lose a life or more in the process, but not lose one at the end of the round. In this case, play advances to the other player if they have lives left.
Thanks so much guys!