subject
Computers and Technology, 21.02.2020 23:41 tia0625

Required Assignment: create a reference and a pointer (C++)a. Create a better dice game. Each player (user or computer) has 2 dices. And you are required to use 1 reference variable and 1 pointer variable. You need to indicate where you use these in your code. b. The winning rule is as follows: if 2 dices of a player have the same value as a pair of 6 and the other player does not have a pair of value then a pair of value will win. So, 5&5 will beat 6&4 because 5&5 is a pair. If both players have pairs, (user and computer), the higher pair will win. For example, 6&6 will beat any pair. If both players do not have pair, then higher total points will win. c. The output of the program may be like the following:Welcome to the dice ware game. You have 100 in your game purse. Enter a bet amount to play (0 means exit the program): 10You have 5 & 5 computer has is 3 & 4You won 10 dollars!Your game purse now has 110 dollarsEnter a bet amount to play (0 means exit the program): 5You have 6 & 4 computer has is 1 & 1You lost 5Your game purse now has 105 dollarsEnter a bet amount to play (0 means exit the program): 10You have 1 & 2 computer has is 3 & 4You lost 10Your game purse now has 95 dollarsEnter a bet amount Enter a bet amount to play (0 means exit the program): 0You choose to exit the program. Thank you and goodbyeUse these class files and create a main://GamePurse. h file#ifndef GamePurse_H#define GamePurse_H//GamePurse class declarationclass GamePurse { int purseAmount; // in main. cpp initialize it to 100public: GamePurse(int); void Win(int); void Loose(int);int GetAmount();};#endif//GamePurse. cpp file#include "GamePurse. h"//constructor implementationGamePurse::GamePurse( int balance){ //initializing purseAmount to 0 purseAmount=0; //if balance is positive, updating purseAmount if(balance>0){ purseAmount=balance; }}//Win method implementationvoid GamePurse::Win(int amount){ //adding amount to purseAmount if amount is positive if(amount>0){ purseAmount+=amount; }}//Loose method implementationvoid GamePurse::Loose(int amount){ //subtracting amount from purseAmount if amount is positive and has enough balance if(amount>0 && purseAmount>=amount){ purseAmount-=amount; }}//GetAmount method implementationint GamePurse::GetAmount(){ return purseAmount;}// DICEROLL. H FILE#ifndef DICEROLL_H#define DICEROLL_Hclass DiceRoll{ public: DiceRoll(int=0); void rollDice(); int getRoll() const; private: int rollValue;};#endif// DICEROLL. CPP FILE#include "DiceRoll. h"# includeusing namespace std;DiceRoll::DiceRoll(int num) : rollValue(num){}void DiceRoll::rollDice() {rollValue = 1+ rand()%6;}int DiceRoll::getRoll() const { return rollValue; }// main. cpp // (not whole program) : below is older version. The newer version needs the requirements above(took out code)#include "GamePurse. h"#include "DiceRoll. h"using namespace std;int main(){(took out code) GamePurse purse(100);DiceRoll player;DiceRoll computer;(took out code)do {cout << "Enter cin >> betMoney;cout << endl; if(betAmt>0){ //checking if there is enough balance or not if(betAmt>purse. GetAmount()){ cout<<"You don't have that much amount to bet"< }else{player. rollDice();computer. rollDice(); //displaying both cout<<"Your dice is "<< player. getRoll()<< endl; cout<<"Computer dice is "<< computer. getRoll() << endl; if(player. getRoll()>computer. getRoll()){(took out code) }else if(player. getRoll() < computer. getRoll()){ (took out code) }else{ cout<<"It's a tie!"< } cout<<"Your game purse now has" << purse. GetAmount << "dollars" < } } }while(betAmt!=0); //until betAmt is 0 cout<<"You choose to exit the program. Thank you and goodbye"< return 0;}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 05:30, lexie2751
How do i get rid of my member ship for
Answers: 2
image
Computers and Technology, 24.06.2019 09:50, trenrain
Create a string list. 2. use console. readline() to collect values of firstname, lastname, street, city, state, zip, save them to list. 3. write a simple linq statement, call method uppercasewords() to change first letter to uppercase. 4. create a foreach statment to display the information. public static string uppercasewords(string value) { char[] array = value. tochararray(); if (array. length > = 1) { if (char. islower(array[0])) { array[0] = char. toupper(array[0]); } } for (int i = 1; i < array. length; i++) { if (array[i - 1] == ' ') { if (char. islower(array[i])) { array[i] = char. toupper(array[i]); } } } return new string(array);
Answers: 3
image
Computers and Technology, 24.06.2019 15:50, GreatBaconGamer
Subscribe to j p g a m e t u b e on you tube ?
Answers: 2
image
Computers and Technology, 24.06.2019 21:00, gabrielaperezcz
How does a vaccine prevent sickness and individual?
Answers: 2
You know the right answer?
Required Assignment: create a reference and a pointer (C++)a. Create a better dice game. Each player...

Questions in other subjects:

Konu
Mathematics, 01.04.2021 19:40