-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentAspirant.cpp
More file actions
84 lines (70 loc) · 1.89 KB
/
StudentAspirant.cpp
File metadata and controls
84 lines (70 loc) · 1.89 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
#include <iostream>
#include <string>
#include <locale>
using namespace std;
class Student {
protected:
string firstName;
string lastName;
string group;
double averageMark;
public:
Student(string firstname, string lastname, string Group, double AverageMark) {
firstName = firstname;
lastName = lastname;
group = Group;
averageMark = AverageMark;
}
string getFirstName() {
return firstName;
}
string getLastName() {
return lastName;
}
string getGroup() {
return group;
}
virtual double getAverageMark() {
return averageMark;
}
virtual double getScholarship() {
if (getAverageMark() == 5.0)
return 2000;
else
return 1900;
}
};
class Aspirant : public Student
{
private:
string scientificWork;
public:
Aspirant(string firstname, string lastname, string Group, double AverageMark, string ScientificWork)
:Student(firstname, lastname, Group, AverageMark)
{
scientificWork = ScientificWork;
}
string getScientificWork() {
return scientificWork;
}
double getScholarship() override {
if (getAverageMark() == 5.0)
return 2500;
else
return 2200;
}
};
int main() {
setlocale(LC_ALL, "RUS");
Student* students[3] = {
new Student("Èâàí", "Èâàíîâ", "Ãðóïïà 1", 4.8),
new Aspirant("Ïåòð", "Ïåòðîâ", "Ãðóïïà 2", 5.0, "Íàçâàíèå íàó÷íîé ðàáîòû"),
new Student("Ñèäîð", "Ñèäîðîâ", "Ãðóïïà 3", 4.5)
};
for (int i = 0; i < 3; ++i) {
cout << "Ñòóäåíò " << students[i]->getFirstName() << " " << students[i]->getLastName()
<< ", ñòèïåíäèÿ: " << students[i]->getScholarship() << endl;
delete students[i];
}
return 0;
}