• 课程设计


    #include<iostream>
    #include<cstring>
    #include<fstream>
    #include<ostream>
    #include<string>
    # define maxn 1010
    using namespace std;
    bool IsExit[maxn];
    int num;
    class TimetoDay//小时转换为天数
    {
    public:
        double Change(double t)
        {
            return t*1.0/8.0;
        }
    } q1;
    class PersonIllWithoutMoneyTime:public TimetoDay//将病假放入一个类中,并且继承第一个类
    {
    public:
        double IllWithoutMoneyTime;
        bool JudgeillwithoutMoneyTime()
        {
            if(IllWithoutMoneyTime>=0&&IllWithoutMoneyTime<=2)
            {
                return true;
            }
            return false;
        }
    };
    class PersonRestwithoutMoneyTime:public TimetoDay//将带薪休假放入一个类中,并且集成第一个类
    {
    public:
        double  RestWithMoneyTime;
        bool JudgeRestWithMoneyTime()
        {
            if(RestWithMoneyTime>=0&&RestWithMoneyTime<=3)
            {
                return true;
            }
            return false;
        }

    };
    class PeopleBasicMessage: public PersonIllWithoutMoneyTime,public PersonRestwithoutMoneyTime
    {
    public:
        int Num;
        string Name;
        char Sex;
        string Department;
        int Rating;
        PeopleBasicMessage() {};
        PeopleBasicMessage(int n1,string str1,char s1,string str2,int s2)
        {
            Num=n1;
            Name=str1;
            Sex=s1;
            Department=str2;
            Rating=s2;
        }//构造函数

    } Man[maxn];
    class Operator:public PeopleBasicMessage//操作,包括查询操作,删减操作等等
    {
    public:
        void SearchMessagebyNum(int num)
        {
            if(IsExit[num]==true)
            {
                cout<<"编号 "<<"姓名  "<<"性别 "<<"工作岗位 "<<"工作等级 "<<"带病休假的时间 "<<"带薪休假的时间 "<<endl;
                cout<<num<<"   "<<Man[num].Name<<"     "<<Man[num].Sex<<"  "<<Man[num].Department<<"      "<<Man[num].Rating<<"     "<<Man[num].IllWithoutMoneyTime<<"                "<<Man[num].RestWithMoneyTime<<endl;
                return ;
            }
            cout<<"找不到这个人的信息!!!"<<endl;
        }
        void SearchMessagebyName(string name)
        {
            int flag=0;
            for(int i=1; i<= maxn; i++)
            {
                if(Man[i].Name==name&&IsExit[i]==true)
                {
                    flag=1;
                    cout<<i<<" "<<Man[i].Name<<" "<<Man[i].Sex<<" "<<Man[i].Department<<" "<<Man[i].Rating<<" "<<Man[i].IllWithoutMoneyTime<<" "<<Man[i].RestWithMoneyTime<<endl;
                    break;
                }
            }
            if(flag==0)
            {
                cout<<"查无此人"<<endl;
            }
            //return ;
        }
        void PrintAllMessage()
        {
            for(int i=1; i<maxn; i++)
            {
                if(IsExit[i]==true)
                {
                    cout<<"编号 "<<"姓名  "<<"性别 "<<"工作岗位 "<<"工作等级 "<<"带病休假的时间 "<<"带薪休假的时间 "<<endl;
                    cout<<i<<"     "<<Man[i].Name<<"   "<<Man[i].Sex<<"     "<<Man[i].Department<<"       "<<Man[i].Rating<<"        "<<Man[i].IllWithoutMoneyTime<<"           "<<Man[i].RestWithMoneyTime<<endl;
                }
            }
        }
        void ChangeMessage(int num,string name,char sex,string department,int rating,int illWithoutMoneyTime,int restWithMoneyTime)
        {
            Man[num].Name=name;
            Man[num].Sex=sex;
            Man[num].Department=department;
            Man[num].Rating=rating;
            Man[num].IllWithoutMoneyTime=illWithoutMoneyTime;
            Man[num].RestWithMoneyTime=restWithMoneyTime;
        }
        void  CalculateFourKindPersonMessage()
        {
            int t1=0,t2=0,t3=0,t4=0;
            for(int i=1; i<=maxn; i++)
            {
                if(IsExit[i]==false)continue;
                if(Man[i].Department=="Manage")
                    t1++;
                if(Man[i].Department=="Technician")
                    t2++;
                if(Man[i].Department=="SaleMan")
                    t3++;
                if(Man[i].Department=="SaleManager")
                    t4++;
            }
            cout<<"经理人数为 "<<" "<<t1<<endl;
            cout<<"技术人员人数为 "<<" "<<t2<<endl;
            cout<<"销售人员人数为 "<<" "<<t3<<endl;
            cout<<"销售经理人数为 "<<" "<<t4<<endl;
            cout<<"总人数为 "<<" "<<t1+t2+t3+t4<<endl;
        }
        void CalculatePeopleMessage(int num)
        {
            if(IsExit[num]==false)
            {
                cout<<"查无此人"<<endl;
                return ;
            }
            cout<<"该员工生病不工作的时间为  "<<Man[num].IllWithoutMoneyTime<<endl;
            cout<<"该员工带薪休假的时间为  "<<Man[num].RestWithMoneyTime<<endl;
        }
        void CalculateSexMessage()
        {
            int t1=0,t2=0;
            for(int i=1; i<=maxn; i++)
            {
                if(IsExit[i]==false)continue;
                if(Man[i].Sex=='m')
                {
                    t1++;
                }
                else
                {
                    t2++;
                }
            }
            cout<<"男人的数目是"<<" "<<t1<<endl;
            cout<<"女人的数目是"<<" "<<t2<<endl;
        }
        void CalculateRatingMessage()
        {
            int t1=0,t2=0,t3=0,t4=0;
            for(int i=1; i<=maxn; i++)
            {
                if(IsExit[i]==false)continue;
                if(Man[i].Rating==1)t1++;
                if(Man[i].Rating==2)t2++;
                if(Man[i].Rating==3)t3++;
                if(Man[i].Rating==4)t4++;
            }
            cout<<"等级一的人数是 "<<" "<<t1<<endl;
            cout<<"等级二的人数是 "<<" "<<t2<<endl;
            cout<<"等级三的人数是 "<<" "<<t3<<endl;
            cout<<"等级四的人数是 "<<" "<<t4<<endl;
        }
        void CalculateOffMessage(int t)
        {
            if(IsExit[t]==false)
            {
                cout<<"查无此人 "<<endl;
                return ;
            }
            cout<<"此人带薪休假的天数  "<<" "<<Man[t].RestWithMoneyTime<<endl;
            cout<<"此人带病休假的天数  "<<" "<<Man[t].IllWithoutMoneyTime<<endl;
            int k1=0,k2=0;
            if(Man[t].RestWithMoneyTime>3)
            {
                k1=1;
                cout<<"这个人带薪休假天数已经超期 "<<endl;
            }
            if(Man[t].IllWithoutMoneyTime>2)
            {
                k2=1;
                cout<<"这个人生病不工作的时间已超期 "<<endl;
            }
            if(k1==0&&k2==0)
            {
                cout<<"这个人的请假时间合格"<<endl;
            }
        }

    } q;

    void Delete(int num)
    {
        IsExit[num]=false;
    }
    void Read()//读取
    {
        ifstream in("data.log");
        for(int i=0; i<=maxn; i++)
        {
        if(IsExit[i]==true||i==8)
            in >> Man[i].Num  >> Man[i].Name  >> Man[i].Sex  >> Man[i].Department  >> Man[i].Rating     >> Man[i].IllWithoutMoneyTime  >> Man[i].RestWithMoneyTime ;
        }
        in.close();
    }
    void save(int num)//存储
    {
        ofstream out("data.log");
        for(int i=1; i<=maxn; i++)
        {
        if(IsExit[i]==true)
            out << Man[i].Num << "    " << Man[i].Name << "    " << Man[i].Sex << "    " << Man[i].Department << "    " << Man[i].Rating << "    "    << Man[i].IllWithoutMoneyTime << "    " << Man[i].RestWithMoneyTime << endl;
        }
        out.close();
    }
    int main()
    {
        memset(IsExit,false,sizeof(IsExit));//首先对isexit这个数组进行赋值,初始值全部设置为false,如果当前编号下有人的话,改为true
        Man[1].Name="张红";
        Man[1].Sex='f';
        Man[1].Department="Manager";
        Man[1].Rating=1;
        Man[1].IllWithoutMoneyTime=0;
        Man[1].RestWithMoneyTime=0;
        Man[2].Name="立白";
        Man[2].Sex='m';
        Man[2].Department="Technician";
        Man[2].Rating=2;
        Man[2].IllWithoutMoneyTime=0;
        Man[2].RestWithMoneyTime=0;
        Man[3].Name="小明";
        Man[3].Sex='f';
        Man[3].Department="SaleMan";
        Man[3].Rating=3;
        Man[3].IllWithoutMoneyTime=0;
        Man[3].RestWithMoneyTime=0;
        Man[4].Name="瓦加";
        Man[4].Sex='m';
        Man[4].Department="SaleManager";
        Man[4].Rating=4;
        Man[4].IllWithoutMoneyTime=0;
        Man[4].RestWithMoneyTime=0;
        Man[5].Name="菲菲";
        Man[5].Sex='f';
        Man[5].Department="Manager";
        Man[5].Rating=1;
        Man[5].IllWithoutMoneyTime=0;
        Man[5].RestWithMoneyTime=0;//原始数据
        for(int i=1; i<=5; i++)
        {
          Man[i].Num=i;
            IsExit[i]=true;
        }
        IsExit[8]=true;
        cout<<"************************************************************************"<<endl;
        cout<<"                                                            "<<endl;
        cout<<"                         公司员工考勤管理系统               "<<endl;
        cout<<"                                                            "<<endl;
        cout<<"                                                            "<<endl;
        cout<<"          进入系统请输入1                    退出请输入2    "<<endl;
        cout<<"**********************************************************************"<<endl;
        int tq;
        cin>>tq;
        num=5;
        if(tq==2)//这是一个开关,如果是1的话,进入系统,如果是2 ,退出
        {
            return 0;
        }
        int flag=2;
        while(1)
        {
            if(flag==1)
            {
                break;
            }//在最后面,如果是退出的话,输入1,当为1的时候,退出循环
            cout<<"                               功能表                "<<endl;
            cout<<"               添加功能--------------------->请输入1 "<<endl;
            cout<<"               查询功能--------------------->请输入2 "<<endl;
            cout<<"               显示功能--------------------->请输入3 "<<endl;
            cout<<"               编辑功能--------------------->请输入4 "<<endl;
            cout<<"               删除功能--------------------->请输入5 "<<endl;
            cout<<"               统计功能--------------------->请输入6 "<<endl;
            cout<<"               保存功能--------------------->请输入7 "<<endl;
            cout<<"               读取功能--------------------->请输入8 "<<endl;
            cout<<"                                       "<<endl;
            cout<<"请输入要进行的操作"<<endl;
            int t;
            cin>>t;
            int order;
            string name;
            char sex;
            string Department;
            int rating;
            int IllWithoutMoneyTime;
            int RestWithMoneyTime;
            if(t==1)
            {
              int time;
                cout<<"请输入要添加的人的 个数 编号 姓名 性别 岗位 等级 带病休假的时间  带薪休假的时间 "<<endl;
                cin>>time>>order>>name>>sex>>Department>>rating>>IllWithoutMoneyTime>>RestWithMoneyTime;
                if(IsExit[order]==true)//判断当前编号下是否有人
                {
                    cout<<"该编号下已经有别人的信息存在     "<<endl;
                }
                else
                {
                    Man[order].Num=order;
                    Man[order].Name=name;
                    Man[order].Sex=sex;
                    Man[order].Department=Department;
                    Man[order].Rating=rating;
                    Man[order].IllWithoutMoneyTime=IllWithoutMoneyTime;
                    Man[order].RestWithMoneyTime=RestWithMoneyTime;
                    IsExit[order]=true;
                    cout<<"已经存入!!!"<<endl;
                    num++;
                }
           }
            else if(t==2)//查询功能
            {
                cout<<"通过编号查询请输入1 "<<"  "<<"通过姓名查询请输入2 "<<"  "<<endl;
                int temp;
                cin>>temp;
                if(temp==1)
                {
                    int w;
                    cout<<"请输入编号  "<<endl;
                    cin>>w;
                    q.SearchMessagebyNum(w);//通过编号查询
                }
                else
                {
                    string s;
                    cin>>s;
                    q.SearchMessagebyName(s);//通过姓名来查询
                }
            }
            else if(t==3)
            {
                q.PrintAllMessage();//打印所有的信息
            }
            else if(t==4)//编辑功能,主要是对等级,两个时间的修改,以及岗位的修改
            {
                cout<<"修改等级---------------->请输入1"<<endl;
                cout<<"修改带病休假时间(hour)-------->请输入2"<<endl;
                cout<<"修改带薪休假时间(hour)-------->请输入3"<<endl;
                cout<<"修改岗位---------------->请输入4"<<endl;
                int e;
                cin>>e;
                if(e==1)//修改等级
                {
                    cout<<"请输入 被修改人的编号 以及 修改后等级"<<endl;
                    int g1,g2;
                    cin>>g1>>g2;
                    if(IsExit[g1]==false)
                    {
                        cout<<" 查无此人!!!"<<endl;
                    }
                    else
                    {
                        Man[g1].Rating=g2;
                        cout<<"修改完成!!!"<<endl;
                    }
                }
                if(e==2)//修改病假的时间
                {
                    cout<<"请输入 被修改人的编号"<<endl;
                    int  g1;
                    double g2;
                    cin>>g1;
                    if(IsExit[g1]==false)
                    {
                        cout<<" 查无此人!!!"<<endl;
                    }
                    else
                    {
                        cout<<"请输入增加的时间(hour)"<<endl;
                        cin>>g2;
                        double temp=q1.Change(g2*1.0)>0 ? q1.Change(g2*1.0):0;
                        Man[g1].IllWithoutMoneyTime= Man[g1].IllWithoutMoneyTime+temp>0?Man[g1].IllWithoutMoneyTime+temp:0;
                    }
                }
                if(e==3)//修改带薪休假的时间
                {
                    cout<<"请输入 被修改人的编号"<<endl;
                    int  g1;
                    double g2;
                    cin>>g1;
                    if(IsExit[g1]==false)
                    {
                        cout<<" 查无此人!!!"<<endl;
                    }
                    else
                    {
                        cout<<"请输入要增加的时间(hour)"<<endl;
                        cin>>g2;
                        double  temp=q1.Change(g2)>0 ? q1.Change(g2):0;
                        Man[g1].RestWithMoneyTime= Man[g1].RestWithMoneyTime+temp>0?Man[g1].RestWithMoneyTime+temp:0;
                    }
                }
                if(e==4)//修改岗位
                {
                    cout<<"请输入修改人的编号 和 修改后的岗位 "<<endl;
                    int s;
                    cin>>s;
                    string str;
                    cin>>str;
                    if(IsExit[s]==false)
                    {
                        cout<<"查无此人!!!"<<endl;
                    }
                    else
                    {
                        Man[s].Department=str;
                        cout<<"修改完成!!!"<<endl;
                    }
                }
            }
            else if(t==5)
            {
                int e;
                cout<<"删除带病休假时间-------->请输入1"<<endl;
                cout<<"删除带薪休假时间-------->请输入2"<<endl;
                cout<<"去除某个人的信息-------->请输入3"<<endl;
                cin>>e;
                if(e==1)
                {
                    cout<<"请输入 被修改人的编号"<<endl;
                    int  g1;
                    double g2;
                    cin>>g1;
                    if(IsExit[g1]==false)
                    {
                        cout<<" 查无此人!!!"<<endl;
                    }
                    else
                    {
                        cout<<"请输入修改的时间"<<endl;
                        cin>>g2;
                        double  temp=q1.Change(g2)>0 ? q1.Change(g2):0;
                        Man[g1].IllWithoutMoneyTime=Man[g1].IllWithoutMoneyTime-temp >0 ?Man[g1].IllWithoutMoneyTime-temp:0;
                        cout<<"修改完成!!!"<<endl;
                    }
                }
                if(e==2)
                {
                    cout<<"请输入 被修改人的编号"<<endl;
                    int  g1;
                    double g2;
                    cin>>g1;
                    if(IsExit[g1]==false)
                    {
                        cout<<" 查无此人!!!"<<endl;
                    }
                    else
                    {
                        cout<<"请输入要改变的时间"<<endl;
                        cin>>g2;
                        double  temp=q1.Change(g2)>0 ? q1.Change(g2):0;
                        Man[g1].RestWithMoneyTime=Man[g1].RestWithMoneyTime-temp >0 ?Man[g1].RestWithMoneyTime-temp:0;
                        cout<<"修改完成!!!"<<endl;
                    }
                }
                if(e==3)
                {
                    int g;
                    cout<<"请输入要删除的人的编号"<<endl;
                    cin>>g;
                    if(IsExit[g]==false)
                    {
                        cout<<"查无此人!!"<<endl;
                    }
                    else
                    {
                        Delete(g);
                        cout<<"删除完成!!!"<<endl;
                    }
                }
            }
            else if(t==6)
            {
                cout<<"统计四类人员的数目和总数---------------> 请输入1 "<<endl;
                cout<<"统计某员工的请假情况-------------------> 请输入2"<<endl;
                cout<<"统计男女人数的情况---------------------> 请输入3"<<endl;
                cout<<"统计不同等级对应人数-------------------> 请输入4 "<<endl;
                cout<<"统计员工的请假情况---------------------> 请输入5 "<<endl;
                int testnum;
                cin>>testnum;
                if(testnum==1)
                {
                    q.CalculateFourKindPersonMessage();
                }
                else if(testnum==2)
                {
                    int g;
                    cout<<"请输入员工编号  "<<endl;
                    cin>>g;
                    q.CalculatePeopleMessage(g);
                }
                else if(testnum==3)
                {
                    q.CalculateSexMessage();
                }
                else if(testnum==4)
                {
                    q.CalculateRatingMessage();
                }
                else if(testnum==5)
                {
                    int s;
                    cout<<"请输入要查询的编号 "<<endl;
                    cin>>s;
                    cout<<"带薪休假天数最多为 3天"<<"  "<<"生病可以不工作的时间最多为 2天"<<endl;
                    q.CalculateOffMessage(s);
                }
            }
            else if(t==7)
            {
                save(num);
                cout<<"保存成功!"<<endl;
            }
            else if(t == 8)
            {
                Read();
                cout<<"读取成功!"<<endl;
            }
            cout<<endl;
            cout<<"退出请输入1 "<<"  "<<"回到主菜单请输入2 "<<endl;
            cin>>flag;
        }
        return 0;
    }
  • 相关阅读:
    8. 使用Java+TestNG+Selenium搭建测试框架做Web UI自动化测试
    7. Selenium的基本使用
    6. Selenium测试工具简介
    4.自动化测试框架及知识体系
    3.当前主流自动化测试工具的对比选型
    2.自动化测试策略
    1.自动化测试概述
    eclipse工程当中的.classpath 和.project文件什么作用?
    Git 命令
    删除指定字符串的算法题,面试时候没做出来
  • 原文地址:https://www.cnblogs.com/letlifestop/p/10263000.html
Copyright © 2020-2023  润新知