Файл заголовка класса проигрывателя:
Код: Выделить всё
#pragma once
#include
using namespace std;
class player
{
private:
string playername;
int hitrate;
int score;
bool won;
public:
void setup_playername(string newplayername)
{
playername = newplayername;
}
void setup_hitrate(int newhitrate)
{
hitrate = newhitrate;
}
void setup_score(int newscore)
{
score = newscore;
}
void setup_won(int newwon)
{
won = newwon;
}
};
Код: Выделить всё
#include
#include
#include
#include "Player.h"
using namespace std;
int create_player()
{
int joerate = 71, sidrate = 73;
int joescore = 501, sidscore = 501;
bool joewon = false, sidwon = false;
player joe;
joe.setup_playername("Joe");
joe.setup_hitrate(joerate);
joe.setup_score(joescore);
joe.setup_won(joewon);
player sid;
sid.setup_playername("Sid");
sid.setup_hitrate(sidrate);
sid.setup_score(sidscore);
sid.setup_won(sidwon);
return joerate, sidrate, joescore, sidscore, joewon, sidwon;
}
string decide_stratagey(int joescore, int sidscore)
{
string jstrat = "";
if (joescore > 170)
{
jstrat = "throwtreble20";
}
else if (joescore > 131)
{
jstrat = "throw treble";
}
else if (joescore > 41)
{
jstrat = "throw double";
}
else if (joescore == 2)
{
jstrat = "throw single";
}
else if (joescore == 1)
{
jstrat = "bullseye";
}
return jstrat;
}
int calcreqdouble(string jstrat, int joescore)
{
int reqdbl = joescore/2;
return reqdbl;
}
int throw_bull(int p) {
// Throw for the bull with accuracy p% (20
int r = rand() % 100;
if (r < (p - 20))
return 50;
else if (r < 85)
return 25;
else
return 1 + rand() % 20;
}
int throw_treble(int d, int p) {
// return result of throwing for treble d with accuracy p% (o
Подробнее здесь: [url]https://stackoverflow.com/questions/78432526/c-darts-project-not-sending-score-to-display[/url]
Мобильная версия