Question
Hello there! I cannot get this code to work as you will see in a picture below with the error notifications, can you help? It
Hello there! I cannot get this code to work as you will see in a picture below with the error notifications, can you help? It needs to be cleaned and for example the HTML needs to be removed (it is in bold now): Thank you!
#include
#include
#include
#include
class Player {
private:
std::string name;
int points;
int counter;
float percentage;
int yes_counter;
public:
Player(std::string name) : name(name), points(0), counter(0),
percentage(0), yes_counter(0) {}
std::string get_name() { return name; }
int get_points() { return points; }
Player* has_won() {
if (points == 50) {
return this;
}
return nullptr;
}
void add_points(int pts) {
counter += 1;
points += pts;
if (pts > 0) {
add_average(pts);
}
if (points > 50) {
points = 25;
std::cout
}
else if (pts > (points / counter)) {
std::cout
}
if (points >= 40 && points
std::cout
}
}
void add_average(int pts) {
if (pts > 0) {
yes_counter += 1;
percentage = (yes_counter / (float)counter) * 100;
}
else if (yes_counter == 0) {
return;
}
percentage = (yes_counter / (float)counter) * 100;
}
std::string get_average() {
std::stringstream ss;
ss
return ss.str();
}
};
int main() {
Player *player1 = new Player("Matti");
Player *player2 = new Player("Teppo");
int throw = 1;
while (true) {
Player *in_turn;
if (throw % 2 == 0) {
in_turn = player1;
}
else {
in_turn = player2;
}
int pts;
std::cout get_name() `oaicite:{"index":0,"invalid_reason":"Malformed citation cin >>"}` pts;
in_turn->add_points(pts);
in_turn->add_average(pts);
if (in_turn->has_won()) {
std::cout get_name()
return 0;
}
std::cout
std::cout
std::cout get_name()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started