-
Notifications
You must be signed in to change notification settings - Fork 1
/
rankedteam.h
104 lines (94 loc) · 3 KB
/
rankedteam.h
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
/** \file rankedteam.h
* \brief Contains the class for a ranked team and problem.
*/
#ifndef RANKEDTEAM_H
#define RANKEDTEAM_H
#include <QObject>
#include <QHash>
#include "defines.h"
#include "contest.h"
namespace DJ {
namespace Model {
/** A ranked problem.
*/
struct RankedProblem {
QString id; /**< The ID of this problem. */
QString shortname; /**< The short name of this problem. */
ProblemState problemState; /**< The state of this problem. */
int tries; /**< The number of tries for this problem until correct one. */
int total_tries; /**< The number of total tries for this problem. */
int timeLastTry; /**< The time of the last try for this problem. */
int timeFirstCorrectTry; /**< The time of the last (propably) correct try for this problem. */
/** Makes a copy of a ranked problem.
*/
RankedProblem *copy() {
RankedProblem *c = new RankedProblem();
c->id = this->id;
c->shortname = this->shortname;
c->problemState = this->problemState;
c->tries = this->tries;
c->total_tries = this->total_tries;
c->timeLastTry = this->timeLastTry;
c->timeFirstCorrectTry = this->timeFirstCorrectTry;
return c;
}
};
/** A ranked team.
*/
class RankedTeam : public QObject {
Q_OBJECT
public:
/** Constructs a new ranked team.
* \param id The unique ID for this ranked team.
* \param name The name of this team.
* \param parent The parent of this object.
*/
explicit RankedTeam(QString id, QString name, QObject *parent = 0);
/** Adds / updates a problem.
* \param id The ID of the problem to add / update.
* \param problem The new problem.
*/
void setProblem(QString id, RankedProblem *problem, Contest *contest);
/** Returns the number of solved problems.
* \return the number of solved problems.
*/
int getNumSolved();
/** Returns the total time for thist eam.
* \return The total time for thist eam.
*/
int getTotalTime();
/** Returns the name of this team.
* \return The name of this team.
*/
QString getName();
/** Returns the ID of this team.
* \return The ID of this team.
*/
QString getId();
/** Returns the number of problems.
* \return The number of problems.
*/
int getNumProblems();
/** Returns the i-th problem for this team.
* \param i The index to use.
* \return The i-th problem for this team.
*/
RankedProblem *getProblem(int i);
/** Returns the problem for the given ID.
* \param id The ID to search.
* \pre The problem with the specified ID exists.
* \return The problem for the given ID.
*/
RankedProblem *getProblemById(QString id);
private:
void recalculateData(Contest *contest);
QString name;
QString id;
QList<RankedProblem *> problems;
QHash<QString, int> problemsHash;
int numSolved;
int totalTime;
};
} // namespace Model
} // namespace DJ
#endif // RANKEDTEAM_H