c++课程设计-简单的员工管理系统

1.问题描述

设计一个计算机程序,能够实现简单的员工管理功能。

2.实习要求

(1)每个员工的信息包括:编号、姓名、性别、出生年月、学历、职务、电话、住址等。

(2)系统的功能包括:

   (a)查询:按特定条件查找员工。

   (b)修改:按编号对某个员工的某项信息进行修改。

   (c)插入:加入新员工的信息。

   (d)删除:按编号删除已离职员工的信息。

   (e)排序:按特定条件对所有员工的信息进行排序。

员工基类:staff.h

class Staff{
    private:
        string id;         //编号
        string name;       //姓名
        string sex;        //性别
        string birthday;      //生日
        string study;         //学历
        string job;         //职务
        string tel;         //电话
        string address;      //住址
    public:
        //数据的get set方法
        void setId(string Id);
        string getId();
        void setName(string Name);
        string getName();
        void setSex(string Sex);
        string getSex();
        void setBirthday(string Birthday);
        string getBirthday();
        void setStudy(string Study);
        string getStudy();
        void setJob(string Job);
        string getJob();
        void setTel(string Tel);
        string getTel();
        void setAddress(string Address);
        string getAddress();
};
void Staff::setId(string Id){
    id = Id;
}
string Staff::getId(){
    return id;
}
void Staff::setName(string Name){
    name = Name;
}
string Staff::getName(){
    return name;
}
void Staff::setSex(string Sex){
    sex = Sex;
}
string Staff::getSex(){
    return sex;
}
void Staff::setBirthday(string Birthday){
    birthday = Birthday;
}
string Staff::getBirthday(){
    return birthday;
}
void Staff::setStudy(string Study){
    study = Study;
}
string Staff::getStudy(){
    return study;
}
void Staff::setJob(string Job){
    job = Job;
}
string Staff::getJob(){
    return job;
}
void Staff::setTel(string Tel){
    tel = Tel;
}
string Staff::getTel(){
    return tel;
}
void Staff::setAddress(string Address){
    address = Address;
}
string Staff::getAddress(){
    return address;
}

 

功能文件:util.h

#include "staff.h"
#include 
Staff S[1000000], S1[1000000];
int NUMBER = 0;
int chooes = 1, chooes1 = 1;
string temp, temp1, temp2, temp3, temp4;

bool cmp(Staff a, Staff b){
    if(a.getId().length() != b.getId().length()) return a.getId().length() > b.getId().length();
    else return a.getId() > b.getId();
}

/*------------初始化系统--------------*/
void init(){
    S[0].setId("10");S[0].setName("dancheng");S[0].setSex("男");S[0].setBirthday("19970211");S[0].setStudy("本科");S[0].setJob("无");S[0].setTel("15043646837");S[0].setAddress("通榆");
    S[1].setId("2");S[1].setName("xinyu");S[1].setSex("男");S[1].setBirthday("19970211");S[1].setStudy("专科");S[1].setJob("无");S[1].setTel("15043646837");S[1].setAddress("通榆");
    S[2].setId("8");S[2].setName("baolei");S[2].setSex("男");S[2].setBirthday("19970211");S[2].setStudy("硕士");S[2].setJob("无");S[2].setTel("15043646837");S[2].setAddress("通榆");
    S[3].setId("1");S[3].setName("xiaoming");S[3].setSex("男");S[3].setBirthday("19970211");S[3].setStudy("博士");S[3].setJob("无");S[3].setTel("15043646837");S[3].setAddress("通榆");
    S[4].setId("5");S[4].setName("fei");S[4].setSex("男");S[4].setBirthday("19970211");S[4].setStudy("专科");S[4].setJob("无");S[4].setTel("15043646837");S[4].setAddress("通榆");
    S[5].setId("7");S[5].setName("baixin");S[5].setSex("男");S[5].setBirthday("19970211");S[5].setStudy("本科");S[5].setJob("无");S[5].setTel("15043646837");S[5].setAddress("通榆");
    S[6].setId("9");S[6].setName("chou");S[6].setSex("男");S[6].setBirthday("19970211");S[6].setStudy("专科");S[6].setJob("无");S[6].setTel("15043646837");S[6].setAddress("通榆");
    S[7].setId("6");S[7].setName("duang");S[7].setSex("男");S[7].setBirthday("19970211");S[7].setStudy("专科");S[7].setJob("无");S[7].setTel("15043646837");S[7].setAddress("通榆");
    S[8].setId("11");S[8].setName("weige");S[8].setSex("男");S[8].setBirthday("19970211");S[8].setStudy("本科");S[8].setJob("无");S[8].setTel("15043646837");S[8].setAddress("通榆");
    S[9].setId("3");S[9].setName("haisong");S[9].setSex("男");S[9].setBirthday("19970211");S[9].setStudy("硕士");S[9].setJob("无");S[9].setTel("15043646837");S[9].setAddress("通榆");
    S[10].setId("4");S[10].setName("zhipeng");S[10].setSex("男");S[10].setBirthday("19970211");S[10].setStudy("博士");S[10].setJob("无");S[10].setTel("15043646837");S[10].setAddress("通榆");
    NUMBER += 11;
}

/*-------------查询-------------------*/
//查询全部员工信息
void findAll(){
    if(NUMBER == 0){
        cout<

 

主执行文件:staff.cpp

#include 
#include 
using namespace std;
#include "util.h"
int main(){
    while(1){
        cout<<"                       +-------------------------------+"<>temp;
        cout<= "0" && temp <= "2" && temp.length() == 1){
            if(temp == "1"){
                chooes = 1;
                while(chooes){
                    cout<<"                       +-------------------------------+"<>temp1;
                    cout<= "0" && temp1 <= "5" && temp1.length() == 1){
                        chooes1 = 1;
                        //------------------查询
                        if(temp1 == "1"){
                            while(chooes1){
                                cout<<"                       +-------------------------------+"<>temp2;
                                cout<= "0" && temp2 <= "9" && temp2.length() == 1){
                                    if(temp2 == "1"){
                                        findAll();
                                    } else if(temp2 == "2"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffById(temp3);
                                    } else if(temp2 == "3"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByName(temp3);
                                    } else if(temp2 == "4"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffBySex(temp3);
                                    } else if(temp2 == "5"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByBirthday(temp3);
                                    } else if(temp2 == "6"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByStudy(temp3);
                                    } else if(temp2 == "7"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByJob(temp3);
                                    } else if(temp2 == "8"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByTel(temp3);
                                    } else if(temp2 == "9"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByAddress(temp3);
                                    } else {
                                        chooes1 = 0;
                                    }
                                }
                            }
                        //------------------修改
                        } else if(temp1 == "2"){
                            while(chooes1){
                                cout<<"                       +-------------------------------+"<>temp2;
                                cout<= "0" && temp2 <= "8" && temp2.length() == 1){
                                    findAll();
                                    if(temp2 == "1"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateId(temp3, temp4);
                                    } else if(temp2 == "2"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateName(temp3, temp4);
                                    } else if(temp2 == "3"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateSex(temp3, temp4);
                                    } else if(temp2 == "4"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateBirthday(temp3, temp4);
                                    } else if(temp2 == "5"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateStudy(temp3, temp4);
                                    } else if(temp2 == "6"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateJob(temp3, temp4);
                                    } else if(temp2 == "7"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateTel(temp3, temp4);
                                    } else if(temp2 == "8"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateAddress(temp3, temp4);
                                    } else {
                                        chooes1 = 0;
                                    }
                                }
                            }
                        //------------------插入
                        } else if(temp1 == "3"){
                            string iid, nname, ssex, bbirthday, sstudy, jjob, ttel, aadress;
                            cout<<"                       +-------------****--------------+"<>iid;
                            cout<<"                  |        请输入你要添加员工的姓名:";
                            cin>>nname;
                            cout<<"                  |        请输入你要添加员工的性别:";
                            cin>>ssex;
                            cout<<"                  |        请输入你要添加员工的生日:";
                            cin>>bbirthday;
                            cout<<"                  |        请输入你要添加员工的学历:";
                            cin>>sstudy;
                            cout<<"                  |        请输入你要添加员工的职位:";
                            cin>>jjob;
                            cout<<"                  |        请输入你要添加员工的电话:";
                            cin>>ttel;
                            cout<<"                  |        请输入你要添加员工的地址:";
                            cin>>aadress;
                            add(iid, nname, ssex, bbirthday, sstudy, jjob, ttel, aadress);
                        //------------------删除
                        } else if(temp1 == "4"){
                            cout<<"                       +-------------****--------------+"<>temp3;
                            deleteById(temp3);
                        //------------------排序
                        } else if(temp1 == "5"){
                            sortId();
                        } else {
                            chooes = 0;
                            NUMBER = 0;
                        }
                    } else {
                        cout<>temp1;
                    cout<= "0" && temp1 <= "5" && temp1.length() == 1){
                        chooes1 = 1;
                        //------------------查询
                        if(temp1 == "1"){
                            while(chooes1){
                                cout<<"                       +-------------------------------+"<>temp2;
                                cout<= "0" && temp2 <= "9" && temp2.length() == 1){
                                    if(temp2 == "1"){
                                        findAll();
                                    } else if(temp2 == "2"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffById(temp3);
                                    } else if(temp2 == "3"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByName(temp3);
                                    } else if(temp2 == "4"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffBySex(temp3);
                                    } else if(temp2 == "5"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByBirthday(temp3);
                                    } else if(temp2 == "6"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByStudy(temp3);
                                    } else if(temp2 == "7"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByJob(temp3);
                                    } else if(temp2 == "8"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByTel(temp3);
                                    } else if(temp2 == "9"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        findStaffByAddress(temp3);
                                    } else {
                                        chooes1 = 0;
                                    }
                                }
                            }
                        //------------------修改
                        } else if(temp1 == "2"){
                            while(chooes1){
                                cout<<"                       +-------------------------------+"<>temp2;
                                cout<= "0" && temp2 <= "8" && temp2.length() == 1){
                                    findAll();
                                    if(temp2 == "1"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateId(temp3, temp4);
                                    } else if(temp2 == "2"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateName(temp3, temp4);
                                    } else if(temp2 == "3"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateSex(temp3, temp4);
                                    } else if(temp2 == "4"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateBirthday(temp3, temp4);
                                    } else if(temp2 == "5"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateStudy(temp3, temp4);
                                    } else if(temp2 == "6"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateJob(temp3, temp4);
                                    } else if(temp2 == "7"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateTel(temp3, temp4);
                                    } else if(temp2 == "8"){
                                        cout<<"                       +-------------****--------------+"<>temp3;
                                        cout<<"                       +-------------****--------------+"<>temp4;
                                        updateAddress(temp3, temp4);
                                    } else {
                                        chooes1 = 0;
                                    }
                                }
                            }
                        //------------------插入
                        } else if(temp1 == "3"){
                            string iid, nname, ssex, bbirthday, sstudy, jjob, ttel, aadress;
                            cout<<"                       +-------------****--------------+"<>iid;
                            cout<<"                  |        请输入你要添加员工的姓名:";
                            cin>>nname;
                            cout<<"                  |        请输入你要添加员工的性别:";
                            cin>>ssex;
                            cout<<"                  |        请输入你要添加员工的生日:";
                            cin>>bbirthday;
                            cout<<"                  |        请输入你要添加员工的学历:";
                            cin>>sstudy;
                            cout<<"                  |        请输入你要添加员工的职位:";
                            cin>>jjob;
                            cout<<"                  |        请输入你要添加员工的电话:";
                            cin>>ttel;
                            cout<<"                  |        请输入你要添加员工的地址:";
                            cin>>aadress;
                            add(iid, nname, ssex, bbirthday, sstudy, jjob, ttel, aadress);
                        //------------------删除
                        } else if(temp1 == "4"){
                            cout<<"                       +-------------****--------------+"<>temp3;
                            deleteById(temp3);
                        //------------------排序
                        } else if(temp1 == "5"){
                            sortId();
                        } else {
                            chooes = 0;
                            NUMBER = 0;
                        }
                    } else {
                        cout<

 

你可能感兴趣的:(算法与数据结构-课程设计)