diff --git a/work20220325/.idea/.gitignore b/work20220325/.idea/.gitignore
new file mode 100644
index 0000000..1c2fda5
--- /dev/null
+++ b/work20220325/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/work20220325/.idea/deployment.xml b/work20220325/.idea/deployment.xml
new file mode 100644
index 0000000..771f492
--- /dev/null
+++ b/work20220325/.idea/deployment.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/work20220325/.idea/misc.xml b/work20220325/.idea/misc.xml
new file mode 100644
index 0000000..f1c67df
--- /dev/null
+++ b/work20220325/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/work20220325/.idea/modules.xml b/work20220325/.idea/modules.xml
new file mode 100644
index 0000000..205aaad
--- /dev/null
+++ b/work20220325/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/work20220325/.idea/vcs.xml b/work20220325/.idea/vcs.xml
new file mode 100644
index 0000000..2e3f692
--- /dev/null
+++ b/work20220325/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/work20220325/.idea/work20220325.iml b/work20220325/.idea/work20220325.iml
new file mode 100644
index 0000000..6d70257
--- /dev/null
+++ b/work20220325/.idea/work20220325.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/work20220325/CMakeLists.txt b/work20220325/CMakeLists.txt
new file mode 100644
index 0000000..6937c04
--- /dev/null
+++ b/work20220325/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.21)
+project(work20220325)
+
+set(CMAKE_CXX_STANDARD 14)
+
+add_executable(work20220325 main.cpp person/Person.cpp person/Person.h date/Date.cpp date/Date.h person/students/Student.cpp person/students/Student.h person/teachers/Teacher.cpp person/teachers/Teacher.h person/students/Graduate.cpp person/students/Graduate.h date/Date.cpp date/Date.h person/students/Student.cpp person/students/Student.h person/teachers/Teacher.cpp person/teachers/Teacher.h person/students/Graduate.cpp person/students/Graduate.h person/students/TeachAssistant.cpp person/students/TeachAssistant.h)
diff --git a/work20220325/date/Date.cpp b/work20220325/date/Date.cpp
new file mode 100644
index 0000000..36c5d5e
--- /dev/null
+++ b/work20220325/date/Date.cpp
@@ -0,0 +1,30 @@
+#include
+#include "Date.h"
+
+Date::Date(int year, int month, int day) : year(year), month(month), day(day) {}
+
+Date::Date(const Date &date) : year(date.year),month(date.month), day(date.day) {}
+
+int Date::getYear() const {
+ return year;
+}
+
+int Date::getMonth() const {
+ return month;
+}
+
+int Date::getDay() const {
+ return day;
+}
+
+void Date::setDate(int year, int month, int day) {
+ Date::year = year;
+ Date::month = month;
+ Date::day = day;
+}
+
+std::string Date::toString() const {
+ std::stringstream output;
+ output << year << '-' << month << '-' << day;
+ return output.str();
+}
\ No newline at end of file
diff --git a/work20220325/date/Date.h b/work20220325/date/Date.h
new file mode 100644
index 0000000..9393301
--- /dev/null
+++ b/work20220325/date/Date.h
@@ -0,0 +1,30 @@
+#ifndef WORK20220325_DATE_H
+#define WORK20220325_DATE_H
+
+#include
+
+class Date {
+private:
+ int year;
+ int month;
+ int day;
+public:
+ Date(int year, int month, int day);
+
+ Date() = delete;
+
+ Date(const Date &date);
+
+ int getYear() const;
+
+ int getMonth() const;
+
+ int getDay() const;
+
+ void setDate(int year, int month, int day);
+
+ std::string toString() const;
+};
+
+
+#endif //WORK20220325_DATE_H
diff --git a/work20220325/person/Person.cpp b/work20220325/person/Person.cpp
new file mode 100644
index 0000000..20c446e
--- /dev/null
+++ b/work20220325/person/Person.cpp
@@ -0,0 +1,22 @@
+#include
+#include
+#include "Person.h"
+
+Person::Person(const std::string& id, const std::string &name, char sex, const std::string &identNumber,
+ const Date &birthday) : id(id), name(name), sex(sex), identNumber(identNumber), birthday(birthday) {}
+
+Person::Person(const Person &person) : id(person.id), name(person.name), sex(person.sex),
+ identNumber(person.identNumber),
+ birthday(person.birthday) {}
+
+std::string Person::toString() {
+ std::stringstream output;
+ output
+ << "编号:" << id << '\n'
+ << "姓名:" << name << '\n'
+ << "性别:" << sex << '\n'
+ << "身份证号:" << identNumber << '\n'
+ << "出生日期:" << birthday.toString() << '\n';
+
+ return output.str();
+}
diff --git a/work20220325/person/Person.h b/work20220325/person/Person.h
new file mode 100644
index 0000000..b1a77f8
--- /dev/null
+++ b/work20220325/person/Person.h
@@ -0,0 +1,29 @@
+#ifndef WORK20220325_PERSON_H
+#define WORK20220325_PERSON_H
+
+#include
+#include "../date/Date.h"
+
+class Person {
+protected:
+ std::string id;
+ std::string name;
+ char sex;
+ std::string identNumber;
+ Date birthday;
+public:
+ const static char SEX_MALE = 'M';
+ const static char SEX_FEMALE = 'F';
+
+ Person(const std::string &id, const std::string &name, char sex, const std::string &identNumber,
+ const Date &birthday);
+
+ Person() = delete;
+
+ Person(const Person &person);
+
+ virtual std::string toString();
+};
+
+
+#endif //WORK20220325_PERSON_H
diff --git a/work20220325/person/students/Graduate.cpp b/work20220325/person/students/Graduate.cpp
new file mode 100644
index 0000000..cc8255e
--- /dev/null
+++ b/work20220325/person/students/Graduate.cpp
@@ -0,0 +1,22 @@
+#include
+#include "Graduate.h"
+
+Graduate::Graduate(const std::string &id, const std::string &name, char sex, const std::string &identNumber,
+ const Date &birthday, int classId, const std::string &subject, const Teacher &adviser,
+ const Person &person) :
+ Student(id, name, sex, identNumber, birthday, classId), subject(subject), adviser(adviser), Person(person) {}
+
+Graduate::Graduate(int classId, const Person &person, const std::string &subject, const Teacher &adviser) : Student(
+ classId, person), subject(subject), adviser(adviser), Person(person) {}
+
+Graduate::Graduate(const Graduate &graduate) : subject(graduate.subject), adviser(graduate.adviser),
+ Student(graduate), Person(graduate) {}
+
+std::string Graduate::toString() {
+ std::stringstream output;
+ output << Student::toString() << '\n'
+ << "专业:" << subject << '\n'
+ << "导师:{ \n" << adviser.toString() << " \n}" << '\n';
+
+ return output.str();
+}
diff --git a/work20220325/person/students/Graduate.h b/work20220325/person/students/Graduate.h
new file mode 100644
index 0000000..71b8469
--- /dev/null
+++ b/work20220325/person/students/Graduate.h
@@ -0,0 +1,25 @@
+#ifndef WORK20220325_GRADUATE_H
+#define WORK20220325_GRADUATE_H
+
+#include "Student.h"
+#include "../teachers/Teacher.h"
+
+class Graduate : public Student {
+protected:
+ std::string subject;
+ Teacher adviser;
+public:
+ Graduate() = delete;
+
+ Graduate(const std::string &id, const std::string &name, char sex, const std::string &identNumber,
+ const Date &birthday, int classId, const std::string &subject, const Teacher &adviser, const Person &person);
+
+ Graduate(const Graduate &graduate);
+
+ Graduate(int classId, const Person &person, const std::string &subject, const Teacher &adviser);
+
+ std::string toString();
+};
+
+
+#endif //WORK20220325_GRADUATE_H
diff --git a/work20220325/person/students/Student.cpp b/work20220325/person/students/Student.cpp
new file mode 100644
index 0000000..0cff4c1
--- /dev/null
+++ b/work20220325/person/students/Student.cpp
@@ -0,0 +1,29 @@
+#include
+#include
+#include "Student.h"
+
+Student::Student(int classId, const Person &person) : classId(classId), Person(person) {}
+
+Student::Student(const Student &student) : classId(student.classId), Person(student) {}
+
+int Student::getClassId() const {
+ return classId;
+}
+
+void Student::setClassId(int classId) {
+ Student::classId = classId;
+}
+
+std::string Student::toString() {
+ std::stringstream output;
+ output
+ << Person::toString() << '\n'
+ << "班级:" << classId;
+
+ return output.str();
+}
+
+Student::Student(const std::string &id, const std::string &name, char sex, const std::string &identNumber,
+ const Date &birthday, int classId)
+ : Person(id, name, sex, identNumber, birthday), classId(classId) {}
+
diff --git a/work20220325/person/students/Student.h b/work20220325/person/students/Student.h
new file mode 100644
index 0000000..2863825
--- /dev/null
+++ b/work20220325/person/students/Student.h
@@ -0,0 +1,29 @@
+#ifndef WORK20220325_STUDENT_H
+#define WORK20220325_STUDENT_H
+
+
+#include "../Person.h"
+
+class Student : virtual public Person {
+protected:
+ int classId;
+
+public:
+ Student() = delete;
+
+ Student(int classId, const Person &person);
+
+ Student(const Student &student);
+
+ Student(const std::string &id, const std::string &name, char sex, const std::string &identNumber,
+ const Date &birthday, int classId);
+
+ int getClassId() const;
+
+ void setClassId(int classId);
+
+ std::string toString();
+};
+
+
+#endif //WORK20220325_STUDENT_H
diff --git a/work20220325/person/students/TeachAssistant.cpp b/work20220325/person/students/TeachAssistant.cpp
new file mode 100644
index 0000000..bd5f7a7
--- /dev/null
+++ b/work20220325/person/students/TeachAssistant.cpp
@@ -0,0 +1,15 @@
+#include
+#include "TeachAssistant.h"
+
+TeachAssistant::TeachAssistant(int classId, const Person &person, const std::string &subject, const Teacher &adviser,
+ const std::string &job, const std::string &department)
+ : Graduate(classId, person, subject, adviser), Teacher(person, job, department), Person(person) {}
+
+std::string TeachAssistant::toString() {
+ std::stringstream output;
+ output << "[研究生身份信息]" << '\n'
+ << Graduate::toString() << '\n'
+ << "[教师身份信息]" << '\n'
+ << Teacher::toString();
+ return output.str();
+}
\ No newline at end of file
diff --git a/work20220325/person/students/TeachAssistant.h b/work20220325/person/students/TeachAssistant.h
new file mode 100644
index 0000000..a05607c
--- /dev/null
+++ b/work20220325/person/students/TeachAssistant.h
@@ -0,0 +1,20 @@
+#ifndef WORK20220325_TEACHASSISTANT_H
+#define WORK20220325_TEACHASSISTANT_H
+
+#include "Student.h"
+#include "../teachers/Teacher.h"
+#include "Graduate.h"
+
+class TeachAssistant : public Graduate , Teacher {
+public:
+ TeachAssistant(int classId, const Person &person, const std::string &subject, const Teacher &adviser,
+ const std::string &job, const std::string &department);
+
+ TeachAssistant() = delete;
+
+ std::string toString();
+
+};
+
+
+#endif //WORK20220325_TEACHASSISTANT_H
diff --git a/work20220325/person/teachers/Teacher.cpp b/work20220325/person/teachers/Teacher.cpp
new file mode 100644
index 0000000..dc98778
--- /dev/null
+++ b/work20220325/person/teachers/Teacher.cpp
@@ -0,0 +1,16 @@
+#include
+#include "Teacher.h"
+
+Teacher::Teacher(const Person &person, const std::string &job, const std::string &department) :
+ Person(person), job(job), department(department) {}
+
+Teacher::Teacher(const Teacher &teacher) : department(teacher.department), job(teacher.job), Person(teacher) {}
+
+std::string Teacher::toString() {
+ std::stringstream output;
+ output << Person::toString() + '\n'
+ << "部门:" << department << '\n'
+ << "职务" << job << '\n';
+
+ return output.str();
+}
\ No newline at end of file
diff --git a/work20220325/person/teachers/Teacher.h b/work20220325/person/teachers/Teacher.h
new file mode 100644
index 0000000..783a620
--- /dev/null
+++ b/work20220325/person/teachers/Teacher.h
@@ -0,0 +1,22 @@
+#ifndef WORK20220325_TEACHER_H
+#define WORK20220325_TEACHER_H
+
+
+#include "../Person.h"
+
+class Teacher : virtual Person {
+protected:
+ std::string job;
+ std::string department;
+public:
+ Teacher(const Person &person, const std::string &job, const std::string &department);
+
+ Teacher(const Teacher &teacher);
+
+ Teacher() = delete;
+
+ virtual std::string toString();
+};
+
+
+#endif //WORK20220325_TEACHER_H