累了,测试等会再写,先push上去备份备份

main
lensfrex 3 years ago
parent a45d364c6d
commit 707145a984
Signed by: lensfrex
GPG Key ID: 0F69A0A2FBEE98A0
  1. 8
      work20220325/.idea/.gitignore
  2. 14
      work20220325/.idea/deployment.xml
  3. 4
      work20220325/.idea/misc.xml
  4. 8
      work20220325/.idea/modules.xml
  5. 6
      work20220325/.idea/vcs.xml
  6. 2
      work20220325/.idea/work20220325.iml
  7. 6
      work20220325/CMakeLists.txt
  8. 30
      work20220325/date/Date.cpp
  9. 30
      work20220325/date/Date.h
  10. 22
      work20220325/person/Person.cpp
  11. 29
      work20220325/person/Person.h
  12. 22
      work20220325/person/students/Graduate.cpp
  13. 25
      work20220325/person/students/Graduate.h
  14. 29
      work20220325/person/students/Student.cpp
  15. 29
      work20220325/person/students/Student.h
  16. 15
      work20220325/person/students/TeachAssistant.cpp
  17. 20
      work20220325/person/students/TeachAssistant.h
  18. 16
      work20220325/person/teachers/Teacher.cpp
  19. 22
      work20220325/person/teachers/Teacher.h

@ -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

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="remote_linux (563cc454-127a-4c53-a847-5bf281087bb1)">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/work20220325.iml" filepath="$PROJECT_DIR$/.idea/work20220325.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

@ -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)

@ -0,0 +1,30 @@
#include <sstream>
#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();
}

@ -0,0 +1,30 @@
#ifndef WORK20220325_DATE_H
#define WORK20220325_DATE_H
#include <string>
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

@ -0,0 +1,22 @@
#include <iostream>
#include <sstream>
#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();
}

@ -0,0 +1,29 @@
#ifndef WORK20220325_PERSON_H
#define WORK20220325_PERSON_H
#include <string>
#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

@ -0,0 +1,22 @@
#include <sstream>
#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();
}

@ -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

@ -0,0 +1,29 @@
#include <iostream>
#include <sstream>
#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) {}

@ -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

@ -0,0 +1,15 @@
#include <sstream>
#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();
}

@ -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

@ -0,0 +1,16 @@
#include <sstream>
#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();
}

@ -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
Loading…
Cancel
Save