-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskeleton.cpp
More file actions
102 lines (59 loc) · 2.09 KB
/
skeleton.cpp
File metadata and controls
102 lines (59 loc) · 2.09 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
#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;
// Do not modify
class Student {
public:
string name;
map<string, int> scores;
Student() {} // Default constructor
Student(string name) : name(name) {}
void addScore(string subject, int score) {
scores[subject] = score;
}
};
class School {
private:
// Do not modify
map<string, Student> students; // Key: Student ID, Value: Student object
public:
void addStudent(string id, string name, map<string, int> subjects) {
// TODO
// if succeeded, cout << "Added " << name << " with ID " << id << endl;
// if duplicated, cout << "Student with ID " << id << " already exists." << endl;
}
void updateScore(string id, string subject, int score) {
// TODO
// if succeeded, cout << "Updated " << subject << " score for " << id << " to " << score << endl;
// if not found, cout << "Student with ID " << id << " not found." << endl;
}
void deleteStudent(string id) {
// TODO
// if succeeded, cout << "Deleted student with ID " << id << endl;
// if not found, cout << "Student with ID " << id << " not found." << endl;
}
void printStudent(string id) {
// TODO
// if succeeded, name, ID: ~~, Scores: subject1 score1, subject2 score2 ~~~
// if not found, cout << "Student with ID " << id << " not found." << endl;
}
void printAllStudents() {
// TODO
// cout << "- " << name << ", ID: " << id << endl;
}
};
int main() {
// Do not modify main function
School mySchool;
// sample
mySchool.addStudent("20230001", "student1", {{"Math", 95}, {"Science", 89}, {"English", 92}});
mySchool.addStudent("20230002", "student2", {{"Math", 80}, {"Science", 100}, {"English", 90}});
mySchool.printAllStudents();
mySchool.updateScore("20230001", "Math", 98);
mySchool.printStudent("20230001");
mySchool.deleteStudent("20230002");
mySchool.printAllStudents();
return 0;
}