Make a class called Dice given or mole You will have the fol
Make a class called Dice (given or mole). You will have the following private attribute, int dice. Make a function to throw the dice.
Make a class named Board, which will have as private attributes dice * dice1 and dice * dice2
Utilizing random, you will print the values of the dices given on the screen
You must use dynamic memory.
Output:
Dice1: 4
Dice2: 6
Solution
#include <iostream>
#include <stdlib.h>
using namespace std;
class Dice
{
private:
int dice;
public:
Dice()
{
dice = 0;
}
void throwDice()
{
dice = rand()%6+1;
}
int diceValue()
{
return dice;
}
};
class Board
{
private:
Dice *dice1,*dice2;
public:
Board()
{
dice1 = new Dice;
dice2 = new Dice;
dice1->throwDice();
dice2->throwDice();
}
void print()
{
cout << \"Dice1 : \" << dice1->diceValue() << endl;
cout << \"Dice2 : \" << dice2->diceValue() << endl;
}
};
int main() {
// your code goes here
Board *b = new Board();
b->print();
return 0;
}

