Question: This Program must be written in C++ ///player.cpp///// #include Player.h Player::Player(const string& new_name) { setName(new_name); } string Player::getName() const { return name; } int Player::getPoints()

This Program must be written in C++

 This Program must be written in C++ ///player.cpp///// #include "Player.h" Player::Player(const

///player.cpp/////

#include "Player.h"

Player::Player(const string& new_name)

{

setName(new_name);

}

string Player::getName() const

{

return name;

}

int Player::getPoints() const

{

return points;

}

void Player::setName(const string& new_name)

{

name = new_name;

}

void Player::setPoints(int new_points)

{

points = new_points;

}

////Player.h////

#pragma once

#include

using namespace std;

class Player

{

public:

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

string getName() const;

int getPoints() const;

void setName(const string& new_name);

void setPoints(int new_points);

private:

string name;

int points;

};

////source.cpp////

#include

#include

#include

#include

#include

#include "Player.h"

using namespace std;

int main()

{

const int M = 37;

const int N = 5;

Player player[N];

player[0].setName("Edd"); player[0].setPoints(0);

player[1].setName("Ged"); player[1].setPoints(0);

player[2].setName("Jed"); player[2].setPoints(0);

player[3].setName("Ted"); player[3].setPoints(0);

player[4].setName("Zed"); player[4].setPoints(0);

bool lostTurn[] = { 0, 0, 0, 0, 0 };

default_random_engine dre(static_cast(time(0)));

uniform_int_distribution player_uid(0, N - 1);

uniform_int_distribution dice_uid(1, 6);

int index = player_uid(dre);

do

{

index = (index + 1) % N;//creates a circular array

if (lostTurn[index] == true)

{

lostTurn[index] = false;

cout

}

else

{

int die1 = dice_uid(dre);

int die2 = dice_uid(dre);

int points = player[index].getPoints() + die1 + +die2;

player[index].setPoints(points);

if (points > M)

{

points = points / 2;

lostTurn[index] = true;

player[index].setPoints(points);

cout

}

else

cout

}

}

while (player[index].getPoints() != M);

cout

system("pause");

return 0;

}

The program stores the players in an array. Modify the program so that it stores the players in an vector Read the number of players, N, and maximum allowed points M from a text file. A player loses half of his points and his next turn when his points are greater than M. The game immediately removes half the player's points and saves the lost turn information in the array lostTurn. Add a lost turn property to the player's properties and an accessor and mutator to manage the lost turn property. Further modify the game so that the player gets an extra turn when the two dice turn up with the same number. For example, the player rolls 2 sixes. This creates an interesting situation: when a player rolls 2 sixes and the player's points are greater than M. What happens to the player? The player loses half of his points but does not ose his next Upload only 3 files-source.cpp, player.cpp, and player.h The program stores the players in an array. Modify the program so that it stores the players in an vector Read the number of players, N, and maximum allowed points M from a text file. A player loses half of his points and his next turn when his points are greater than M. The game immediately removes half the player's points and saves the lost turn information in the array lostTurn. Add a lost turn property to the player's properties and an accessor and mutator to manage the lost turn property. Further modify the game so that the player gets an extra turn when the two dice turn up with the same number. For example, the player rolls 2 sixes. This creates an interesting situation: when a player rolls 2 sixes and the player's points are greater than M. What happens to the player? The player loses half of his points but does not ose his next Upload only 3 files-source.cpp, player.cpp, and player.h

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!