-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProblem.cpp
More file actions
81 lines (70 loc) · 1.59 KB
/
Problem.cpp
File metadata and controls
81 lines (70 loc) · 1.59 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
#include "Problem.h"
#include "FunctionLibrary.h"
Problem::Problem(const std::string _id, const std::string _title, const std::string _teacherName, const std::string _requirement, const unsigned int _maxNum)
:id(_id),
title(_title),
teacherName(_teacherName),
requirement(_requirement),
maxNum(_maxNum),
nowNum(0)
{
}
Problem::~Problem()
{
id = '\0';
title = '\0';
teacherName = '\0';
requirement = '\0';
maxNum = 0;
nowNum = 0;
}
std::string Problem::GetID() const
{
return id;
}
std::string Problem::GetTitle() const
{
return title;
}
std::string Problem::GetTeacher() const
{
return teacherName;
}
unsigned int Problem::GetMaxNumber() const
{
return maxNum;
}
unsigned int Problem::GetNowNumber() const
{
return nowNum;
}
bool Problem::IsFull() const
{
return (nowNum == maxNum);
}
std::string Problem::Output(OutputMethod method) const
{
std::string result;
switch (method)
{
case OutputMethod::Complete:
result = "编号:" + id + "\n标题:" + title + "\n指导老师:" + teacherName + "\n要求:" + requirement
+ "\n最大选题人数:" + FunctionLibrary::ToString(maxNum) + "\n已选人数:" + FunctionLibrary::ToString(nowNum);
break;
case OutputMethod::Save:
result = id + "\n" + title + "\n" + teacherName + "\n" + requirement
+ "\n" + FunctionLibrary::ToString(maxNum) + "\n" + FunctionLibrary::ToString(nowNum) + "\n";
break;
case OutputMethod::Short:
result = id + ".";
case OutputMethod::IgnoreID:
default:
result += title;
break;
}
return result;
}
bool Problem::operator ==(const Problem& prob) const
{
return (id == prob.GetID() || title == prob.GetTitle()) ? true : false;
}