This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathTeam.cpp
More file actions
121 lines (105 loc) · 2.49 KB
/
Copy pathTeam.cpp
File metadata and controls
121 lines (105 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "Team.h"
#include <iostream>
#include <time.h>
#include <cstdlib>
using namespace std;
Team::Team()
{
for(int i=0; i<10; i++)
comp[i] = new Competitor();
}
Team::~Team()
{
delete [] comp;
}
//////////////////////////////////////////////////////
void Team::SkillsView()
{
for (int i=0; i<10; i++)
{
cout << "competitor nr " << i << ": " << endl;
comp[i]->View();
}
}
//////////////////////////////////////////////////////
void Team::SolveView()
{
for (int i=0; i<10; i++)
cout << "solved " << i << ": " << solve[i] << endl;
}
//////////////////////////////////////////////////////
void Team::PointsView()
{
for (int i=0; i<10; i++)
cout << "points " << i << ": " << points[i] << endl;
}
//////////////////////////////////////////////////////
void Team::ExChoosing()
{
for (int i=0; i<10; i++)
{
Competitor bestCompetitor = *comp[i];
for (int j=i+1; j<9; j++)
{
if (comp[j]->GetSkill(i) > bestCompetitor.skill[i])
bestCompetitor = *comp[j];
}
Competitor tmp = *comp[i];
*comp[i] = bestCompetitor;
bestCompetitor = tmp;
}
}
//////////////////////////////////////////////////////
void Team::ExSolving()
{
srand(time(NULL));
for (int i=0; i<10; i++)
{
int random = rand()%100;
if (random < comp[i]->GetSkill(i))
solve[i]=true;
else
solve[i]=false;
}
}
///////////////////////////////////////////////////////
void Team::ExPoints()
{
srand(time(NULL));
for (int i=0; i<10; i++)
{
if (solve[i]==true)
{
points[i]=6;
for (int j=10; j>6; j--)
{
int random = rand()%100;
if (random < comp[i]->GetChance(i))
{
points[i]=j;
break;
}
}
}
if (solve[i]==false)
{
points[i]=0;
for (int j=5; j>0; j--)
{
int random = rand()%100;
if (random < comp[i]->GetChance(i))
{
points[i]=j;
break;
}
}
}
}
}
///////////////////////////////////////////////////////
void Team::Solving()
{
ExChoosing();
ExSolving();
ExPoints();
}