Modify the code below to create a  "Dice game" program that is contained in 5 files: Dice_game.cpp Dice.cpp Die.cpp Dice.h Die.h ou must include these features: Try-Throw-Catch Use .h and .cpp files for classes Must be your own code written now In DrA’s dice game, you use two dice. On the first roll of the dice the player immediately wins when the roll is 7 or 11, and loses when the roll is 2, 3, or 12. (See below for code to doll a die.) If 4, 5, 6, 8, 9, or 10 is rolled that number becomes the “key." The player keeps rolling the dice until either 7 or the key is rolled. If the key is rolled first, then the player loses. If the player rolls a 7 first, then the player wins. (There is a loop here.) Write a program that plays the game once, using the rules stated above. There is no user input. Run it a few times watching the behavior in the debugger until you are convinced that it is playing by the rules. Instead of asking for a wager, the program should just determine if the player would win or lose. The program should simulate rolling the two dice and calculate the sum. PLEASE MODIFY THE CODE IN FILE dice.h and dice.cpp Dice.cpp #include "Dice.h" Dice::Dice() {} void Dice::add_die(Die die) {     dice.push_back(die); } void Dice::roll_all() {     for (Die& die : dice)     {         die.roll();     } } std::vector Dice::get_dice() const {     return dice; }   Dice.h ifndef DICE_H #define DICE_H #include #include "Die.h" class Dice { private:     std::vector dice; public:     Dice();     void add_die(Die die);     void roll_all();     std::vector get_dice() const; }; #endif // DICE_H

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Modify the code below to create a  "Dice game" program that is contained in 5 files:

  • Dice_game.cpp
  • Dice.cpp
  • Die.cpp
  • Dice.h
  • Die.h

ou must include these features:

  • Try-Throw-Catch
  • Use .h and .cpp files for classes
  • Must be your own code written now

In DrA’s dice game, you use two dice. On the first roll of the dice the player immediately wins when the roll is 7 or 11, and loses when the roll is 2, 3, or 12. (See below for code to doll a die.)

If 4, 5, 6, 8, 9, or 10 is rolled that number becomes the “key."

The player keeps rolling the dice until either 7 or the key is rolled. If the key is rolled first, then the player loses. If the player rolls a 7 first, then the player wins. (There is a loop here.) Write a program that plays the game once, using the rules stated above. There is no user input. Run it a few times watching the behavior in the debugger until you are convinced that it is playing by the rules. Instead of asking for a wager, the program should just determine if the player would win or lose. The program should simulate rolling the two dice and calculate the sum.

PLEASE MODIFY THE CODE IN FILE dice.h and dice.cpp

Dice.cpp

#include "Dice.h"

Dice::Dice() {}

void Dice::add_die(Die die)
{
    dice.push_back(die);
}

void Dice::roll_all()
{
    for (Die& die : dice)
    {
        die.roll();
    }
}

std::vector<Die> Dice::get_dice() const
{
    return dice;
}

 

Dice.h

ifndef DICE_H
#define DICE_H

#include <vector>
#include "Die.h"

class Dice
{
private:
    std::vector<Die> dice;

public:
    Dice();
    void add_die(Die die);
    void roll_all();
    std::vector<Die> get_dice() const;
};

#endif // DICE_H

 

Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY