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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 03:30
Some of your friends have gotten into the burgeoning field of time-series data mining, in which one looks for patterns in sequences of events that occur over time. purchases at stock exchanges--what’s being bought-- are one source of data with a natural ordering in time. given a long sequence s of such events, your friends want an efficient way to detect certain "patterns" in them--for example, they may want to know if the four events buy yahoo, buy ebay, buy yahoo, buy oracle occur in this sequence s, in order but not necessarily consecutively. they begin with a collection of possible events (e.g., the possible’ transactions) and a sequence s of n of these events. a given event may occur multiple times in s (e.g., yahoo stock may be bought many times in a single sequence s). we will say that a sequence s’ is a subsequence of s if there is a way to delete certain of the events from s so that the remaining events, in order, are equal to the sequence s’. so, for example, the sequence of four events above is a subsequence of the sequence buy amazon, buy yahoo, buy ebay, buy yahoo, buy yahoo, buy oracle their goal is to be able to dream up short sequences and quickly detect whether they are subsequences of s. so this is the problem they pose to you: give an algorithm that takes two sequences of even~s--s’ of length m and s of length n, each possibly containing an event more than once--and decides in time o(m n) whether s’ is a subsequence of s
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
Which location-sharing service offers items for users as a gaming component and also allows them to collectively link their check-ins to publish a trip? a. whrrl b. buzzd c. foursquare (this option is wrong i already tried) d. gowalla for plato
Answers: 2
question
Computers and Technology, 22.06.2019 22:50
Which is the best minecraft server? a. mineplex b. worldonecraft c. 9b9t d. 2b2t
Answers: 2
question
Computers and Technology, 23.06.2019 01:30
1. which of the following is a search engine? a) mozilla firefox b)internet explorer c)google d)safari 2. which of the following statements is true? a) all search engines will provide the same results when you enter the same query. b) all search engines use the same amount of advertisements. c) some search engines are also browsers. d) search engines often provide different results, even when you enter the same query.
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
question
Mathematics, 18.10.2019 00:20
question
Computers and Technology, 18.10.2019 00:30
question
History, 18.10.2019 00:30
Questions on the website: 13722360