• 实验:编写一个人员信息管理系统。这个系统的功能是:交互式的实现校园人员信息的录入与显示。


    学校里,主要有四类人员:大学本科学生、教师、研究生和助教。
    大学本科生每周有固定的学时数。教师除了固定的学时数外,还有每周的教学时数。研究生除了固定的学时数外,每周还可以自由做一定的研究。助教生除了上课外,还要做研究和一定的教学工作。
    人员的基本信息包括姓名、编号、性别、身份证号、总学时数以及每周固定学时数。各个人员之间的关系: people类派生出student 类和teacher类,student 类派生出graduate类, graduate类和teacher类派生出TA类。

    //people.h
    #include<iostream>
    #include<string>
    using namespace std;
    class people
    {
    public:
    people();
    people( string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week);//对数据初始化
    void show();
    string sexwm(char sex);
    ~people();
    protected:
    string name;//姓名
    int number;//编号
    char sex;//性别
    int id;//身份证号
    int sum;//总学时数
    int week;//周固定学时数
    };
    //people.cpp
    #include "pch.h"
    #include "people.h"


    people::people()
    {
    }


    people::people(string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week)
    {
    name = m_name;
    number = m_number;
    sex = m_sex;
    id = m_id;
    sum = m_sum;
    week = m_week;
    }

    void people::show()
    {
    cout << "人员信息" << endl;
    }
    string people::sexwm(char sex)
    {
    if (sex == 'm') return "man";
    else return "woman";
    }

    people::~people()
    {
    }
    //student.h
    #pragma once
    #include "people.h"
    class student :virtual public people
    {
    public:
    student();
    student( string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week);
    void show();
    ~student();
    };
    //student.cpp
    #include "pch.h"
    #include "student.h"


    student::student()
    {
    }

    student::student(string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week)
    {
    name = m_name;
    number = m_number;
    sex = m_sex;
    id = m_id;
    sum = m_sum;
    week = m_week;
    }
    void student::show()
    {
    cout << "姓名" << ' ' << "编号" << ' ' << "性别" << ' ' << "身份证号" << ' ' << "总学时" << ' ' << "周固定学时" << endl;
    cout << name << ' ' << number << ' ' << sexwm(sex) << ' ' << id << ' ' << sum << ' ' << week << endl;
    }


    student::~student()
    {
    }
    //teacher.h
    #pragma once
    #include "people.h"
    class teacher :virtual public people
    {
    public:
    teacher();
    teacher(string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week,int m_teach);
    void show();
    ~teacher();
    protected:
    int teach;//教学时数
    };
    //teacher.cpp
    #include "pch.h"
    #include "teacher.h"


    teacher::teacher()
    {
    }

    teacher::teacher(string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week, int m_teach)
    {
    name = m_name;
    number = m_number;
    sex = m_sex;
    id = m_id;
    sum = m_sum;
    week = m_week;
    teach = m_teach;
    }

    void teacher::show()
    {
    cout << "姓名" << ' ' << "编号" << ' ' << "性别" << ' ' << "身份证号" << ' ' << "总学时" << ' ' << "周固定学时" <<' '<<"教学时数"<< endl;
    cout << name << ' ' << number << ' ' << sexwm(sex) << ' ' << id << ' ' << sum << ' ' << week << ' ' << teach << endl;
    }

    teacher::~teacher()
    {
    }

    //graduate.h
    #pragma once
    #include "student.h"
    class graduate :virtual public student
    {
    public:
    graduate();
    graduate(string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week);
    void show();
    ~graduate();
    };
    //graduate.cpp

    #include "pch.h"
    #include "graduate.h"


    graduate::graduate()
    {
    }

    graduate::graduate(string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week)
    {
    name = m_name;
    number = m_number;
    sex = m_sex;
    id = m_id;
    sum = m_sum;
    week = m_week;
    }
    void graduate::show()
    {
    cout << "姓名" << ' ' << "编号" << ' ' << "性别" << ' ' << "身份证号" << ' ' << "总学时" << ' ' << "周固定学时" << endl;
    cout << name << ' ' << number << ' ' << sexwm(sex) << ' ' << id << ' ' << sum << ' ' << week << endl;
    cout << "可自由做一定研究" << endl;
    }

    graduate::~graduate()
    {
    }

    //TA.h
    #pragma once
    #include "graduate.h"
    #include "teacher.h"
    class TA :
    public graduate,public teacher
    {
    public:
    TA();
    TA(string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week,int teach);
    void show();
    ~TA();
    };
    //TA.cpp
    #include "pch.h"
    #include "TA.h"


    TA::TA()
    {
    }

    TA::TA(string m_name, int m_number, char m_sex, int m_id, int m_sum, int m_week, int m_teach)
    {
    name = m_name;
    number = m_number;
    sex = m_sex;
    id = m_id;
    sum = m_sum;
    week = m_week;
    teach = m_teach;
    }
    void TA::show()
    {
    cout << "姓名" << ' ' << "编号" << ' ' << "性别" << ' ' << "身份证号" << ' ' << "总学时" << ' ' << "周固定学时" << ' ' << "教学时数" << endl;
    cout << name << ' ' << number << ' ' << sexwm(sex) << ' ' << id << ' ' << sum << ' ' << week << ' ' << teach << endl;
    cout << "可自由做一定研究" << endl;
    }
    TA::~TA()
    {
    }

    //main.cpp
    #include "pch.h"
    #include "people.h"
    #include "student.h"
    #include "teacher.h"
    #include "graduate.h"
    #include "TA.h"
    #include <iostream>
    using namespace std;
    int main(http://www.my516.com)
    {
    student a("a", 1, 'm', 1801, 100, 10);
    a.show();
    teacher b("b", 2, 'w', 1802, 100, 10, 20);
    b.show();
    graduate c("c", 3, 'm', 1803, 100, 10);
    c.show();
    TA d("d", 4, 'w', 1804, 100, 10, 20);
    d.show();
    }

    ---------------------

  • 相关阅读:
    apply和call详解
    this用法
    jquery的each()详细介绍
    摹客食堂|你真的会做交付文档吗?
    资源分享|找不到素材?这份免费APP UI Kit资源大礼包送给你!
    功能播报|PRD可以在线审阅啦!让文档管理更轻松~
    工具推荐|2019年UI设计师必备工具清单
    案例分析|最佳倒数计时器设计分析【附原型实例】
    摹客食堂|新"葵花宝典"--用户体验设计知识大全
    灵感专题|2019年优秀网页设计作品赏析#9月
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11161449.html
Copyright © 2020-2023  润新知