C++ Programming
You have to implement three classes, namely Player class, Dice class, and Game class, and a driver program test class
INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS
Write a C++ program to implement a three-player dice game with the following rules:
- Begin with Player A and roll two dice: dice d1 and dice
- If the sum of the two dice is odd, then accumulate it as the score of Player A. If even, then the score is
- Then roll d1 and d2 for Player
- If the sum of the two dice is odd, then accumulate it as the score of Player B. If even, then the score is
- Then roll d1 and d2 for Player
- If the sum of the two dice is odd, then accumulate it as the score of Player C. If even, then the score is
- Repeat steps 1 to 6 for n rounds, where n is a positive integer provided as input by the
Things to keep in mind:
- You have to implement three classes, namely Player class, Dice class, and Game class, and a driver program test class that contains the main
- Members of Player class are:
- Instance variables: id, name, and
- Parameterized constructor with arguments as id and
- Method: void updateScore() with argument d1 and d2. This method sums the score for the player.
- Method: String toString() with no argument. This method prints out the player’s name and score value in each
- Member of Dice class is:
- Method: int roll() with no argument. This method rolls the dice and returns a random number between 1 and 6
- Members of Game class are:
- Instance variables: playerA, playerB, playerC, d1, and
- Default constructor which initializes the id and name of each player as well as creates new objects for dice, i.e. d1 and
- Method: Player winner() with arguments Dice1 and Dice2. This method sums the score for the player.
- Method: void play() with no argument. This method contains the loop in which the dice is rolled and score is recorded for each
- Function in the driver program is:
Method: int main(). It is the main method in which an object of class Game is created and the method play() is invoked.
Related Questions
. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java
CS 340 Milestone One Guidelines and Rubric
Overview: For this assignment, you will implement the fundamental operations of create, read, update,
. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class
Retail Transaction Programming Project
Project Requirements:
Develop a program to emulate a purchase transaction at a retail store. This
. The following program contains five errors. Identify the errors and fix them
7COM1028
Secure Systems Programming
Referral Coursework: Secure
. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer
CS 340 Final Project Guidelines and Rubric
Overview The final project will encompass developing a web service using a software stack and impleme