Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Part A, you will adapt your game to use the Player module that is provided on the CS 115 website. The Player module is
In Part A, you will adapt your game to use the Player module that is provided on the CS 115 website. The Player module is an encapsulated service that keeps track of the number of players and information for each player. Each player has a name and counts for money, dice, and points. (The dice will be used in Assignment 4). Because the Player module is encapsulated, you will only be able to access its state using the functions that the interface provides. Perform the following steps (steps 2 to 4 modify main.cpp): 1. Download the player.h and Player.cpp files from the CS 115 website and add them to your program. Read the comments in Player.h to learn about the functions that are available. 2. Add tincludel "Player.h" to your Main.cpp file. 3. Near the beginning of main, declare an array to hold two player names. Place two names in the array. You may use any names you like as long as they start with different letters. Then initialize the player module by calling playerInit, passing the array of player names as the second parameter. 4. Remove the array of player money from Assignment 1. When the player gains money, call the playerIncreaseMoneyAndPrint function. To print the player money at the end, call the playerPrint function. Hint: The playerPrint function also prints additional information 5. When a player's turn starts, print the player name instead of "Player X". Use the playerGet.Name function rather than your name array. For example, if the player was named "Lin", the message could be printed as: Lin's turn: In Part A, you will adapt your game to use the Player module that is provided on the CS 115 website. The Player module is an encapsulated service that keeps track of the number of players and information for each player. Each player has a name and counts for money, dice, and points. (The dice will be used in Assignment 4). Because the Player module is encapsulated, you will only be able to access its state using the functions that the interface provides. Perform the following steps (steps 2 to 4 modify main.cpp): 1. Download the player.h and Player.cpp files from the CS 115 website and add them to your program. Read the comments in Player.h to learn about the functions that are available. 2. Add tincludel "Player.h" to your Main.cpp file. 3. Near the beginning of main, declare an array to hold two player names. Place two names in the array. You may use any names you like as long as they start with different letters. Then initialize the player module by calling playerInit, passing the array of player names as the second parameter. 4. Remove the array of player money from Assignment 1. When the player gains money, call the playerIncreaseMoneyAndPrint function. To print the player money at the end, call the playerPrint function. Hint: The playerPrint function also prints additional information 5. When a player's turn starts, print the player name instead of "Player X". Use the playerGet.Name function rather than your name array. For example, if the player was named "Lin", the message could be printed as: Lin's turn
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started