c++カリキュラム設計-シンプルな従業員管理システム
18610 ワード
1.問題の説明
簡単な従業員管理機能を実現するコンピュータプログラムを設計します.
2.実習要求
(1)各従業員の情報には、番号、氏名、性別、生年月日、学歴、職務、電話、住所などが含まれる.
(2)システムの機能は以下のとおりである.
(a)クエリー:特定の条件で従業員を検索します.
(b)修正:ある従業員のある情報を番号別に修正する.
(c)挿入:新入社員の加入情報.
(d)削除:離職した従業員の情報を番号別に削除する.
(e)ソート:すべての従業員の情報を特定の条件でソートします.
従業員ベース:staff.h
機能ファイル:util.h
メイン実行ファイル:staff.cpp
簡単な従業員管理機能を実現するコンピュータプログラムを設計します.
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<>nname;
cout<>ssex;
cout<>bbirthday;
cout<>sstudy;
cout<>jjob;
cout<>ttel;
cout<>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<>nname;
cout<>ssex;
cout<>bbirthday;
cout<>sstudy;
cout<>jjob;
cout<>ttel;
cout<>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<