-
Notifications
You must be signed in to change notification settings - Fork 0
/
teacher.h
79 lines (62 loc) · 1.45 KB
/
teacher.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
/*
TeacherÀ࣬ ¼Ì³ÐÓÚPerson
*/
#ifndef TEACHER_H
#define TEACHER_H
#include "person.h"
#include <iostream>
class Teacher : public Person
{
private:
float salary;
std::string subject;
std::string level;
public:
Teacher() {
Person("xiaoMing", "male", 35);
this->salary = 5000;
this->subject = "Math";
this->level = "Professor";
};
~Teacher() {};
Teacher(std::string name, std::string gender, int age, float salary, std::string subject, std::string level) {
this->setName(name);
this->setAge(age);
this->setGender(gender);
this->salary = salary;
this->subject = subject;
this->level = level;
}
public:
//setter
void setSalary(float salary) {
this->salary = salary;
}
void setSubject(std::string subject) {
this->subject = subject;
}
void setLevel(std::string level) {
this->level = level;
}
std::string getSubject() {
return this->subject;
}
float getSalary() {
return this->salary;
}
std::string getLevel() {
return this->level;
}
public:
//ÖØÔØ overload
void eat(const std::string& food) {
std::cout << this->getName() + " " + "eat" + " " + food << std::endl;
}
void eat() {
std::cout << this->getName() + " " + "eat" + " " + "rice(default)" << std::endl;
}
void eat(std::string food, int time) {
std::cout << this->getName() + " " + "eat" + " " + food + ". At " + std::to_string(time) + "clock." << std::endl;
}
};
#endif