Question: Data Structure C++ language class (This is what I have so far and please help finish and provide output) Battle Dice Battle Dice is an

Data Structure C++ language class (This is what I have so far and please help finish and provide output)

Battle Dice

Battle Dice is an 2 player game where 2 players each toss a die 3 times. At each toss, the player whose die shows the larger number wins the toss. If the numbers are equal then no one wins the toss - the toss is tied. The player who wins the greater number of tosses wins the game. if no player wins the greater number of tosses then the player whose die numbers' sum is larger wins the game. If the die numbers' sums are equal then the game is tied. Write a program that simulates one game of Battle Dice. Use arrays and use the Player class in your solution.

Player.h

#pragma once

#include

using namespace std;

class Player

{

public:

//constructor

Player(const string& new_name = "No Name");

//accessors

string name() const;

int sums() const;

int wins() const;

//mutators

void name(const string& new_name) const;

//custom methods

void clear();

void addDie(int new_die);

void addWin();

private:

string _name;

int _sums;

int _wins;

};

Player.cpp

#include "Player.h"

Player::Player(const string& new_name)

{

_name = new_name;

_sums = 0;

_wins = 0;

}

//accessors

string Player::name() const

{

return _name;

}

int Player::sums() const

{

return _sums;

}

int Player::wins() const

{

return _wins;

}

//custom methods

void Player::clear()

{

_sums = 0;

_wins = 0;

}

void Player::addDie(int new_die)

{

_sums += new_die;

}

void Player::addWin()

{

_wins++;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!