C++課程設計——大学人員情報管理システム
コードは臭くて長いです.BUGがあれば、指摘してください.必ずしも変更するとは限りません.ಥ
common.h共有クラス:
tester.h実験員:
teacher.h先生:
administrator.h行政人員:
tea&admi.h教師及び行政人員:
interface.hインタフェース:
myfun.h主な機能実現:
main.cpp主関数:
common.h共有クラス:
#ifndef COMMON_H_INCLUDED
#define COMMON_H_INCLUDED
#include
#include
#include
class COMMON
{
protected:
std::string name;
bool sex;
int age;
std::string id;
static int person_sum;
static int man_sum;
static int woman_sum;
public:
COMMON(std::string a, bool b, int c, std::string d);
virtual ~COMMON();
static int get_person_sum();
static int get_man_sum();
static int get_woman_sum();
virtual void show(){}
virtual void show_row(){}
virtual bool change(){}
std::string get_name(){return name;}
bool get_sex(){return sex;}
int get_age(){return age;}
std::string get_id(){return id;}
};
int COMMON::person_sum = 0;
int COMMON::man_sum = 0;
int COMMON::woman_sum = 0;
int COMMON::get_person_sum()
{
return person_sum;
}
int COMMON::get_man_sum()
{
return man_sum;
}
int COMMON::get_woman_sum()
{
return woman_sum;
}
COMMON::COMMON(std::string a, bool b, int c, std::string d): name(a), sex(b), age(c), id(d)
{
person_sum++;
if(b) man_sum++;
else woman_sum++;
}
COMMON::~COMMON()
{
person_sum--;
if(sex) man_sum--;
else woman_sum--;
}
#endif // COMMON_H_INCLUDED
tester.h実験員:
#ifndef TESTER_H_INCLUDED
#define TESTER_H_INCLUDED
#include"common.h"
class TESTER: public COMMON
{
private:
std::string laboratory;
std::string title;
static int tester_sum;
public:
TESTER(std::string a = "haha", bool b = 1, int c = 19, std::string d = "1",
std::string e = "tt", std::string f = " ");
~TESTER();
static int get_tester_sum();
virtual void show();
virtual void show_row();
virtual bool change();
std::string get_laboratory(){return laboratory;}
std::string get_title(){return title;}
};
int TESTER::tester_sum = 0;
int TESTER::get_tester_sum()
{
return tester_sum;
}
TESTER::TESTER(std::string a, bool b, int c, std::string d, std::string e, std::string f):
COMMON(a,b,c,d), laboratory(e), title(f)
{
tester_sum++;
}
TESTER::~TESTER()
{
tester_sum--;
}
void TESTER::show()
{
std::cout << " :
";
std::cout << " :\t\t" << name << std::endl;
std::cout << " :\t\t";
if(sex) std::cout << "
";
else std::cout << "
";
std::cout << " :\t\t" << age << std::endl;
std::cout << "ID:\t\t" << id << std::endl;
std::cout << " :\t" << laboratory << std::endl;
std::cout << " :\t\t" << title << std::endl;
}
void TESTER::show_row()
{
std::cout << std::left << std::setw(8) << name;
if(sex) std::cout << std::left << std::setw(8) << " ";
else std::cout << std::left << std::setw(8) << " ";
std::cout << std::left << std::setw(8) << age;
std::cout << std::left << std::setw(16) << id;
std::cout << std::left << std::setw(16) << laboratory;
std::cout << std::left << std::setw(16) << title;
std::cout << std::endl;
}
bool TESTER::change()
{
std::cout << " :\t\t" ;
std::string new_name;
std::cin >> new_name;
for(unsigned int i = 0; i < new_name.length(); i++)
{
if(new_name[i] >= '0' && new_name[i] <= '9')
{
std::cout << " ,
";
return 1;
}
}
name = new_name;
std::cout << " :\t\t";
std::string a;
std::cin >> a;
if(sex) man_sum--;
else woman_sum--;
if(a == " ") sex = 1, man_sum++;
else sex = 0, woman_sum++;
std::cout << " :\t\t";
std::cin >> age;
std::cout << " :\t";
std::cin >> laboratory;
std::cout << " :\t\t";
std::cin >> title;
return 0;
}
#endif // TESTER_H_INCLUDED
teacher.h先生:
#ifndef TEACHER_H_INCLUDED
#define TEACHER_H_INCLUDED
#include"common.h"
class TEACHER: virtual public COMMON
{
protected:
std::string department;
std::string profession;
std::string title;
static int teacher_sum;
public:
TEACHER(std::string a = "xixi", bool b = 1, int c = 30, std::string d = "213",
std::string e = " ", std::string f = " ", std::string g = " ");
~TEACHER();
static int get_teacher_sum();
virtual void show();
virtual void show_row();
virtual bool change();
std::string get_department(){return department;}
std::string get_profession(){return profession;}
std::string get_title(){return title;}
};
int TEACHER::teacher_sum = 0;
int TEACHER::get_teacher_sum()
{
return teacher_sum;
}
TEACHER::TEACHER(std::string a, bool b, int c, std::string d, std::string e, std::string f, std::string g):
COMMON(a,b,c,d), department(e), profession(f), title(g)
{
teacher_sum++;
}
TEACHER::~TEACHER()
{
teacher_sum--;
}
void TEACHER::show()
{
std::cout << " :
";
std::cout << " :\t\t" << name << std::endl;
std::cout << " :\t\t";
if(sex) std::cout << "
";
else std::cout << "
";
std::cout << " :\t\t" << age << std::endl;
std::cout << "ID:\t\t" << id << std::endl;
std::cout << " :\t\t" << department << std::endl;
std::cout << " :\t\t" << profession << std::endl;
std::cout << " :\t\t" << title << std::endl;
}
void TEACHER::show_row()
{
std::cout << std::left << std::setw(8) << name;
if(sex) std::cout << std::left << std::setw(8) << " ";
else std::cout << std::left << std::setw(8) << " ";
std::cout << std::left << std::setw(8) << age;
std::cout << std::left << std::setw(16) << id;
std::cout << std::left << std::setw(16) << department;
std::cout << std::left << std::setw(16) << profession;
std::cout << std::left << std::setw(16) << title;
std::cout << std::endl;
}
bool TEACHER::change()
{
std::cout << " :\t\t" ;
std::string new_name;
std::cin >> new_name;
for(unsigned int i = 0; i < new_name.length(); i++)
{
if(new_name[i] >= '0' && new_name[i] <= '9')
{
std::cout << " ,
";
return 1;
}
}
name = new_name;
std::cout << " :\t\t";
std::string a;
std::cin >> a;
if(sex) man_sum--;
else woman_sum--;
if(a == " ") sex = 1, man_sum++;
else sex = 0, woman_sum++;
std::cout << " :\t\t";
std::cin >> age;
std::cout << " :\t\t";
std::cin >> department;
std::cout << " :\t\t";
std::cin >> profession;
std::cout << " :\t\t";
std::cin >> title;
return 0;
}
#endif // TEACHER_H_INCLUDED
administrator.h行政人員:
#ifndef ADMINISTRATOR_H_INCLUDED
#define ADMINISTRATOR_H_INCLUDED
#include"common.h"
class ADMINISTRATOR: virtual public COMMON
{
protected:
std::string politics;
std::string position;
static int administrator_sum;
public:
ADMINISTRATOR(std::string a = "huhu", bool b = 1, int c = 39, std::string d = "176",
std::string e = " ", std:: string f = " ");
~ADMINISTRATOR();
static int get_administrator_sum();
virtual void show();
virtual void show_row();
virtual bool change();
std::string get_politics(){return politics;}
std::string get_position(){return position;}
};
int ADMINISTRATOR::administrator_sum = 0;
int ADMINISTRATOR::get_administrator_sum()
{
return administrator_sum;
}
ADMINISTRATOR::ADMINISTRATOR(std::string a, bool b, int c, std::string d, std::string e, std::string f):
COMMON(a,b,c,d), politics(e), position(f)
{
administrator_sum++;
}
ADMINISTRATOR::~ADMINISTRATOR()
{
administrator_sum--;
}
void ADMINISTRATOR::show()
{
std::cout << " :
";
std::cout << " :\t\t" << name << std::endl;
std::cout << " :\t\t";
if(sex) std::cout << "
";
else std::cout << "
";
std::cout << " :\t\t" << age << std::endl;
std::cout << "ID:\t\t" << id << std::endl;
std::cout << " :\t" << politics << std::endl;
std::cout << " :\t\t" << position << std::endl;
}
void ADMINISTRATOR::show_row()
{
std::cout << std::left << std::setw(8) << name;
if(sex) std::cout << std::left << std::setw(8) << " ";
else std::cout << std::left << std::setw(8) << " ";
std::cout << std::left << std::setw(8) << age;
std::cout << std::left << std::setw(16) << id;
std::cout << std::left << std::setw(16) << politics;
std::cout << std::left << std::setw(16) << position;
std::cout << std::endl;
}
bool ADMINISTRATOR::change()
{
std::cout << " :\t\t" ;
std::string new_name;
std::cin >> new_name;
for(unsigned int i = 0; i < new_name.length(); i++)
{
if(new_name[i] >= '0' && new_name[i] <= '9')
{
std::cout << " ,
";
return 1;
}
}
name = new_name;
std::cout << " :\t\t";
std::string a;
std::cin >> a;
if(sex) man_sum--;
else woman_sum--;
if(a == " ") sex = 1, man_sum++;
else sex = 0, woman_sum++;
std::cout << " :\t\t";
std::cin >> age;
std::cout << " :\t";
std::cin >> politics;
std::cout << " :\t\t";
std::cin >> position;
return 0;
}
#endif // ADMINISTRATOR_H_INCLUDED
tea&admi.h教師及び行政人員:
#ifndef TEAADMI_H_INCLUDED
#define TEAADMI_H_INCLUDED
#include"teacher.h"
#include"administrator.h"
class TEAADMI: public TEACHER, public ADMINISTRATOR
{
private:
static int teaadmi_sum;
public:
TEAADMI(std::string a = "maomao", bool b = 1, int c = 59, std::string d = "0",
std::string e = " ", std::string f = " ", std::string g = " ",
std::string h = " ", std:: string i = " ");
~TEAADMI();
static int get_teaadmi_sum();
virtual void show();
virtual void show_row();
virtual bool change();
};
int TEAADMI::teaadmi_sum = 0;
int TEAADMI::get_teaadmi_sum()
{
return teaadmi_sum;
}
TEAADMI::TEAADMI(std::string a, bool b, int c, std::string d, std::string e, std::string f, std::string g, std::string h, std::string i):
COMMON(a,b,c,d), TEACHER(a,b,c,d,e,f,g), ADMINISTRATOR(a,b,c,d,h,i)
{
teaadmi_sum++;
}
TEAADMI::~TEAADMI()
{
teaadmi_sum--;
}
void TEAADMI::show()
{
std::cout << " :
";
std::cout << " :\t\t" << name << std::endl;
std::cout << " :\t\t";
if(sex) std::cout << "
";
else std::cout << "
";
std::cout << " :\t\t" << age << std::endl;
std::cout << "ID:\t\t" << id << std::endl;
std::cout << " :\t\t" << department << std::endl;
std::cout << " :\t\t" << profession << std::endl;
std::cout << " :\t\t" << title << std::endl;
std::cout << " :\t" << politics << std::endl;
std::cout << " :\t\t" << position << std::endl;
}
void TEAADMI::show_row()
{
std::cout << std::left << std::setw(8) << name;
if(sex) std::cout << std::left << std::setw(8) << " ";
else std::cout << std::left << std::setw(8) << " ";
std::cout << std::left << std::setw(8) << age;
std::cout << std::left << std::setw(16) << id;
std::cout << std::left << std::setw(16) << department;
std::cout << std::left << std::setw(16) << profession;
std::cout << std::left << std::setw(16) << title;
std::cout << std::left << std::setw(16) << politics;
std::cout << std::left << std::setw(16) << position;
std::cout << std::endl;
}
bool TEAADMI::change()
{
std::cout << " :\t\t" ;
std::string new_name;
std::cin >> new_name;
for(unsigned int i = 0; i < new_name.length(); i++)
{
if(new_name[i] >= '0' && new_name[i] <= '9')
{
std::cout << " ,
";
return 1;
}
}
name = new_name;
std::cout << " :\t\t";
std::string a;
std::cin >> a;
if(sex) man_sum--;
else woman_sum--;
if(a == " ") sex = 1, man_sum++;
else sex = 0, woman_sum++;
std::cout << " :\t\t";
std::cin >> age;
std::cout << " :\t\t";
std::cin >> department;
std::cout << " :\t\t";
std::cin >> profession;
std::cout << " :\t\t";
std::cin >> title;
std::cout << " :\t";
std::cin >> politics;
std::cout << " :\t\t";
std::cin >> position;
return 0;
}
#endif // TEA&ADMI_H_INCLUDED
interface.hインタフェース:
#ifndef INTERFACE_H_INCLUDED
#define INTERFACE_H_INCLUDED
#include"teacher.h"
#include"tester.h"
#include"administrator.h"
#include"tea&admi.h"
#include
#include
#include
/*---------------- -------------------*/
void interface_login(); //
void interface_Manager(); //
void staff_list(); //
#include"myfun.h"
/*---------------- -------------------*/
void interface_Manager() //
{
int n=1;
while(n)
{
system("cls");
std::cout << "------------ o(*≧▽≦)ツ----------
";
std::cout << "-----------------------------------------------------------
";
std::cout << "-----------------------------------------------------------
";
std::cout << "------------- 1 -------------
";
std::cout << "------------- 2 -------------
";
std::cout << "------------- 3 -------------
";
std::cout << "------------- 4 -------------
";
std::cout << "------------- 5 -------------
";
std::cout << "------------- 6 -------------
";
std::cout << "------------- 0 -------------
";
std::cout << "-----------------------------------------------------------
";
std::cout << "-----------------------------------------------------------
";
std::cin >> n;
switch(n)
{
case 1:Add_information();break;
case 2:
{
int a = 1;
if(!Query_information()) break;
while(a)
{
std::cout << " 1
";
std::cout << " 2
";
std::cout << " 0
";
std::cin >> a;
switch(a)
{
case 1:Edit_information(); a = 0; break;
case 2:Delete_information(); a= 0; break;
}
}
break;
}
case 3:
{
int a=1;
while(a)
{
Browse_information();
std::cout << " 1
";
std::cout << " 2
";
std::cout << " 0
";
std::cin >> a;
switch(a)
{
case 1:Edit_information(); break;
case 2:Delete_information(); break;
}
}
break;
}
case 4:Edit_information(); break;
case 5:Delete_information(); break;
case 6:count_information(); break;
}
}
}
void interface_login() //
{
int n=1;
while(n)
{
system("cls");
std::cout << "---------- o(*≧▽≦)ツ--------
";
std::cout << "-----------------------------------------------------------
";
std::cout << "-----------------------------------------------------------
";
std::cout << "------------- 1 -------------
";
std::cout << "------------- 2 -------------
";
std::cout << "------------- 3 -------------
";
std::cout << "------------- 4 -------------
";
std::cout << "------------- 5 -------------
";
std::cout << "------------- 0 -------------
";
std::cout << "-----------------------------------------------------------
";
std::cout << "-----------------------------------------------------------
";
std::cin >> n;
switch(n)
{
case 1:login(); break;
case 2:if(Query_information()) std::cout << " ,
", getch(); break;
case 3:Browse_information(); std::cout << " ,
"; getch(); break;
case 4:count_information(); break;
case 5:staff_list(); break;
}
}
}
void staff_list() //
{
system("cls");
std::cout << "-----------------------------------------------------------
";
std::cout << "-----------------------------------------------------------
";
std::cout << "--------------Include the following members----------------
";
std::cout << "-------------- wzy ----------------
";
std::cout << "-------------- ToRe ----------------
";
std::cout << "-----------------------------------------------------------
";
std::cout << "-----------------------------------------------------------
";
std::cout << "
…
";
getch();
}
#endif // INTERFACE_H_INCLUDED
myfun.h主な機能実現:
#ifndef MYFUN_H_INCLUDED
#define MYFUN_H_INCLUDED
#include
#include
main.cpp主関数:
#include"interface.h"
int main()
{
Information_load(); //
interface_login(); //
room_delete(); //
// count_information();
return 0;
}