COS120 Assignment #2 1 COS220 Assignment #12 Due: Sunday 5/2/21 No Late Due Date Worth: 60 points This program practices writing a class and using the class in an application. Task 1: Write the Dice...

1 answer below »
mla not relevant.must be completed in C++all directions are included


COS120 Assignment #2 1 COS220 Assignment #12 Due: Sunday 5/2/21 No Late Due Date Worth: 60 points This program practices writing a class and using the class in an application. Task 1: Write the Dice class implementation Dice.cpp for the header file Dice.h available on Brightspace. Dice.h Task 2: Write an application to play the dice game called Craps. The player rolls the dice. If the first roll is 7 or 11, the player wins. If the first roll is 2, 3, or 12, the player loses. If the first roll is not an automatic win or loss, the first dice value is called the point. The player continues rolling the dice until either the point is rolled (a win) or 7 is rolled (a loss). Compute number of rolls. The player can play the game as often as desired. After the player is done, a report of number of games and win percent is shown. See the sample output for responses. Use correct grammar (singular/plural) with conditional operators in the cout statements. Code Requirements: Code must make use of the Dice class and call Dice public methods whenever possible. 2 Be sure to submit all three files: Dice.h, Dice.cpp, and the main application source code. Submit the output from a sample demonstrating at least one automatic win or loss, one win after rolling the point and one loss after rolling the 7. Example of automatic win Example of loss by rolling 7 Example of win by rolling the point 3
Answered 3 days AfterApr 28, 2021

Answer To: COS120 Assignment #2 1 COS220 Assignment #12 Due: Sunday 5/2/21 No Late Due Date Worth: 60 points...

Aditya answered on May 02 2021
139 Votes
output.JPG
Dice.cpp
Dice.cpp
#include"Dice.h"
Dice::Dice()
{
    die1=1+(rand()%6);
    die2=
1+(rand()%6);
}
Dice::Dice(int d1,int d2)
{
    die1=d1;
    die2=d2;
}
void Dice::setDice(int d1,int d2)
{
    die1=d1;
    die2=d2;
}
int Dice::getTotal()
{
    return die1+die2;
}
void Dice::roll()
{
    die1=1+(rand()%6);
    die2=1+(rand()%6);
}
Dice.h
#pragma once
#include
#include
class Dice
{
private:
int die1;
int die2;
public:
Dice();
Dice(int d1,int d2);
void setDice(int d1,int d2);
int getTotal();
void roll();
};
main.cpp
#include
#include"Dice.h"
using namespace std;
int main()
{
srand(unsigned(time(0)));
Dice dice;
int numberOfWins=0;
int numberOfGames=0;
int c=0;
int...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here