C++實(shí)現(xiàn)圖書(shū)管理系統(tǒng)課程設(shè)計(jì)(面向?qū)ο?
本文實(shí)例為大家分享了C++實(shí)現(xiàn)圖書(shū)管理系統(tǒng)課程設(shè)計(jì),供大家參考,具體內(nèi)容如下
1.題目:
【1】:工作人員登錄后,可以進(jìn)行的操作
添加學(xué)生的信息(學(xué)號(hào),姓名,院系,最大借閱的圖書(shū)數(shù)量等);
修改學(xué)生的信息(學(xué)號(hào),姓名,院系,最大借閱的圖書(shū)數(shù)量等);
刪除學(xué)生的信息(學(xué)號(hào),姓名,院系,最大借閱的圖書(shū)數(shù)量等);
如果某個(gè)學(xué)生退學(xué),就要清除他的信息;
查看學(xué)生的信息;
添加圖書(shū)的信息(圖書(shū)號(hào),書(shū)名,作者,出版社,數(shù)量等);
修改圖書(shū)的信息(圖書(shū)號(hào),書(shū)名,作者,出版社,數(shù)量等);
刪除圖書(shū)的信息(圖書(shū)號(hào),書(shū)名,作者,出版社,數(shù)量等);
查看圖書(shū)的信息;
【2】:學(xué)生登錄后,可以進(jìn)行的操作
查看學(xué)生自己借閱的數(shù)目信息;
借閱圖書(shū);
歸還圖書(shū);
備注:要求將學(xué)生和圖書(shū)信息存放到外存上,每次從外存讀取數(shù)據(jù);
2.代碼
/**
?*項(xiàng)目名稱:圖書(shū)管理系統(tǒng)
?*語(yǔ)言:C++
?**/
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <vector>
#include <stdlib.h>
#include <string.h>
using namespace std;
//構(gòu)建學(xué)生類
class Student
{
public:
?? ?Student()
?? ?{
?? ??? ?memset(s_num, 0, sizeof(s_num));
?? ??? ?memset(s_name,0, sizeof(s_name));
?? ??? ?memset(s_name, 0, sizeof(college, 0, sizeof(college)));
?? ??? ?borrow_max = 0;
?? ??? ?borrow_quantity = 0;
?? ??? ?memset(borrow_books, 0, sizeof(borrow_books));
?? ?}
?? ?char s_num[15];?? //學(xué)號(hào)
?? ?char s_name[10];??//姓名
?? ?char college[30];?//院系
?? ?int borrow_max;?? ??//最大借閱數(shù)量
?? ?int borrow_quantity;?? ??//借閱數(shù)量
?? ?char borrow_books[10][30];?//借閱圖書(shū)
?? ?bool S_SetInto();???//設(shè)置學(xué)生信息
?? ?friend istream& operator>>(istream& in, Student& cp);??//提取運(yùn)算符重載
?? ?friend ostream& operator<<(ostream& out, Student& cp);?//插入運(yùn)算符重載
?? ?bool S_If_match(char p[30]);??//判斷學(xué)號(hào)是否匹配
?? ?void s_display();??//顯示學(xué)生信息
};
//設(shè)置學(xué)生信息
bool Student::S_SetInto()
{
?? ?char temp[15];
?? ?cout << "請(qǐng)輸入學(xué)號(hào):(輸入+退出)";
?? ?cin >> temp;
?? ?if (temp[0] == '+')
?? ?{
?? ??? ?return false;
?? ?}
?? ?strcpy(s_num, temp);
?? ?cout << "學(xué)生姓名:";
?? ?cin >> s_name;
?? ?cout << "院系:";
?? ?cin >> college;
?? ?do
?? ?{
?? ??? ?cout << "最大借閱數(shù)量(1-10):";
?? ??? ?cin >> borrow_max;
?? ?}
?? ?while (borrow_max <= 0 || borrow_max > 10);
?? ?return true;
}
//提取運(yùn)算符重載
istream& operator>>(istream& in, Student& cp)
{
?? ?in >> cp.s_num >> cp.s_name >> cp.college >> cp.borrow_max >> cp.borrow_quantity;
?? ?for (int i = 0; i < cp.borrow_quantity; i++)
?? ?{
?? ??? ?in >> cp.borrow_books[i];
?? ?}
?? ?return in;
}
//插入運(yùn)算符重載
ostream& operator<<(ostream& out, Student& cp)
{
?? ?out << cp.s_num << ' ' << cp.s_name << ' ' << cp.college << ' ' << cp.borrow_max << ' ' << cp.borrow_quantity << ' ';
?? ?for (int i = 0; i < 10; i++)
?? ?{
?? ??? ?out << cp.borrow_books[i] << ' ';
?? ??? ?if (i == 9)
?? ??? ?{
?? ??? ??? ?out << '\n';
?? ??? ?}
?? ?}
?? ?return out;
}
//判斷學(xué)號(hào)是否匹配
bool Student::S_If_match(char p[30])
{
?? ?return (!strcmp(s_num, p)||!strcmp(s_name, p));
}
//顯示學(xué)生信息
void Student::s_display()?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?//顯示
{
?? ?cout << setiosflags(ios::left) << "學(xué)號(hào):" << setw(12) << s_num << " ? ?" << setw(10) << s_name << " ? ?" << setw(25) << college << endl
?? ??? ?<< "最大借閱量" << borrow_max << endl;
}
//構(gòu)建圖書(shū)類
class Book
{
public:
?? ?char b_num[15];?//圖書(shū)號(hào)
?? ?char b_name[30];?//書(shū)名
?? ?char author[20];??//作者
?? ?char p_house[30];?//Publishing House 出版社
?? ?int b_quantity;?? //圖書(shū)數(shù)量
?? ?bool B_SetInto();??? ?//設(shè)置圖書(shū)信息
?? ?friend istream& operator>>(istream& in, Book& cp);?? //提取運(yùn)算符重載
?? ?friend ostream& operator<<(ostream& out, Book& cp);??//插入運(yùn)算符重載
?? ?bool B_If_match(char p[30]);
?? ?void b_display();??//圖書(shū)信息顯示
};
//設(shè)置圖書(shū)信息
bool Book::B_SetInto()
{
?? ?char temp[15];
?? ?cout << "請(qǐng)輸入圖書(shū)號(hào):(輸入+退出)";
?? ?cin >> temp;
?? ?if (temp[0] == '+')
?? ??? ?return false;
?? ?strcpy(b_num, temp);
?? ?cout << "書(shū)名:";
?? ?cin >> b_name;
?? ?cout << "作者:";
?? ?cin >> author;
?? ?cout << "出版社";
?? ?cin >> p_house;
?? ?cout << "數(shù)量:";
?? ?cin >> b_quantity;
?? ?return true;
}
//提取運(yùn)算符重載
istream& operator>>(istream& in, Book& cp)
{
?? ?in >> cp.b_num >> cp.b_name >> cp.author >> cp.p_house >> cp.b_quantity;
?? ?return in;
}
//插入運(yùn)算符重載
ostream& operator<<(ostream& out, Book& cp)
{
?? ?out << cp.b_num <<' '<< cp.b_name <<' '<< cp.author <<' '<< cp.p_house <<' '<< cp.b_quantity<<'\n';
?? ?return out;
}
//判斷圖書(shū)號(hào)是否匹配
bool Book::B_If_match(char p[30])
{
?? ??? ?return (!strcmp(b_num, p)|| !strcmp(b_name, p));
}
//顯示函數(shù)
void Book:: b_display()
{
?? ?cout << setiosflags(ios::left) << setw(12) << b_num << " ? ?" << setw(30) << b_name << " ? ?" << setw(10) << author << endl
?? ??? ?<< setw(20) << p_house << " ? ?" <<"剩余數(shù)量:"<< setw(3) << b_quantity << endl;
}
//構(gòu)建管理類
class management
{
public:
?? ?int s_sum=0;??//學(xué)生數(shù)
?? ?int b_sum=0;??//圖書(shū)數(shù)
?? ?string key;??//管理員密碼
?? ?vector<Student> s_array;??//記錄學(xué)生類
?? ?vector<Book> b_array;?//記錄圖書(shū)類
?? ?void S_clear();??//清理已有學(xué)生信息
?? ?void B_clear();??//清理已有圖書(shū)信息
?? ?void S_Read_file();?//讀取學(xué)生文件
?? ?void S_Save_file();?//保存學(xué)生文件
?? ?void B_Read_file();?//讀取圖書(shū)文件
?? ?void B_Save_file();?//保存圖書(shū)文件
?? ?bool Student_add();?//添加學(xué)生信息
?? ?bool Student_mod();?//修改學(xué)生信息
?? ?bool Student_del();?//刪除學(xué)生信息
?? ?bool Student_scan();??//查看學(xué)生信息
?? ?bool Book_add();??//添加圖書(shū)信息
?? ?bool Book_mod();??//修改圖書(shū)信息
?? ?bool Book_del();??//刪除圖書(shū)信息
?? ?bool Book_scan();?//查看圖書(shū)信息
?? ?bool s_login(Student& cp);?? ?//學(xué)生憑學(xué)號(hào)登錄
?? ?bool borrow_scan(Student &cp);?? //查看借閱數(shù)目
?? ?bool borrow_book(Student &cp);?? //借書(shū)
?? ?bool return_book(Student &cp);?? //還書(shū)
?? ?bool Student_System();???//學(xué)生登錄
?? ?bool Personnel_System();?? ?//工作人員登錄
?? ?void login_init();?? ?//登錄界面初始化
};
//清理已有學(xué)生信息
void management::S_clear()
{
?? ?s_array.clear();
?? ?s_sum = 0;
}
//清理已有圖書(shū)信息
void management::B_clear()
{
?? ?b_array.clear();
?? ?b_sum = 0;
}
//讀取學(xué)生文件
void management::S_Read_file()
{
?? ?ifstream s_file;
?? ?s_file.open("Student_Information.txt");
?? ?if (!s_file.is_open())
?? ?{
?? ??? ?cerr << "文件\"Student_Information.txt\"無(wú)法打開(kāi)\n";
?? ??? ?exit(1);
?? ?}
?? ?while (!(s_file.eof()))
?? ?{
?? ??? ?Student stu;
?? ??? ?s_file >> stu;
?? ??? ?s_array.push_back(stu);
?? ??? ?s_sum++;
?? ?}
?? ?s_sum--;
?? ?s_file.close();
}
//保存學(xué)生文件
void management::S_Save_file()
{
?? ?ofstream s_file("Student_Information.txt");
?? ?if (!s_file)
?? ?{
?? ??? ?cerr << "文件\"Student_Information.txt\"無(wú)法打開(kāi)!\n";
?? ??? ?exit(1);
?? ?}
?? ?int i = -1;
?? ?while (++i < s_sum)
?? ?{
?? ??? ?s_file << s_array[i];
?? ?}
?? ?s_file.close();
}
//讀取圖書(shū)文件
void management::B_Read_file()
{
?? ?ifstream b_file;
?? ?b_file.open("Book_Information.txt");
?? ?if (!b_file.is_open())
?? ?{
?? ??? ?cerr << "文件\"Book_Information.txt\"無(wú)法打開(kāi)\n";
?? ??? ?exit(1);
?? ?}
?? ?while (!b_file.eof())
?? ?{
?? ??? ?Book _book;
?? ??? ?b_file >> _book;
?? ??? ?b_array.push_back(_book);
?? ??? ?b_sum++;
?? ?};
?? ?b_sum--;
?? ?b_file.close();
}
//保存圖書(shū)文件
void management::B_Save_file()
{
?? ?ofstream b_file("Book_Information.txt");
?? ?if (!b_file)
?? ?{
?? ??? ?cerr << "文件\"Book_Information.txt\"無(wú)法打開(kāi)!\n";
?? ??? ?exit(1);
?? ?}
?? ?int i = -1;
?? ?while (++i < b_sum)
?? ?{
?? ??? ?b_file << b_array[i];
?? ?}
?? ?b_file.close();
}
//添加學(xué)生信息
bool management::Student_add()
{
?? ?S_Read_file();
?? ?Student _stu;
?? ?cout << "請(qǐng)進(jìn)行信息錄入。按“+”結(jié)束!\n";
?? ?do
?? ?{
?? ??? ?s_array.push_back(_stu);
?? ?}
?? ?while (s_array[s_sum++].S_SetInto());
?? ?s_sum--;
?? ?s_array.pop_back();
?? ?return true;
}
//修改學(xué)生信息
bool management::Student_mod()
{
?? ?char _s_num[15];
?? ?S_Read_file();
?? ?cout << "請(qǐng)輸入您要修改的學(xué)生信息的學(xué)號(hào)或名字:";
?? ?cin >> _s_num;
?? ?int i = 0;
?? ?for (; i < s_sum; i++)
?? ?{
?? ??? ?if (s_array[i].S_If_match(_s_num))
?? ??? ?{
?? ??? ??? ?cout << "該同學(xué)的原信息為:\n";
?? ??? ??? ?s_array[i].s_display();
?? ??? ??? ?cout << "請(qǐng)輸入正確信息! \n";
?? ??? ??? ?s_array[i].S_SetInto();
?? ??? ??? ?s_sum++;??//保持學(xué)生數(shù)
?? ??? ??? ?return true;
?? ??? ?}
?? ??? ?if (i == s_sum)
?? ??? ?{
?? ??? ??? ?cout << "抱歉!您要修改的信息不存在! " << endl;
?? ??? ??? ?return false;
?? ??? ?}
?? ??? ?break;
?? ?}
}
//刪除學(xué)生信息
bool management::Student_del()
{
?? ?char _s_num[15];
?? ?S_Read_file();
?? ?cout << "請(qǐng)輸入您要?jiǎng)h除的學(xué)生信息的學(xué)號(hào):";
?? ?cin >> _s_num;
?? ?for (int i = 0; i < s_sum; i++)
?? ?{
?? ??? ?if (s_array[i].S_If_match(_s_num))
?? ??? ?{
?? ??? ??? ?cout << "該同學(xué)的原信息為:\n";
?? ??? ??? ?s_array[i].s_display();
?? ??? ??? ?s_array.erase(s_array.begin() + i);
?? ??? ??? ?s_sum--;
?? ??? ??? ?return true;
?? ??? ?}
?? ??? ?if (i == s_sum)
?? ??? ?{
?? ??? ??? ?cout << "抱歉!您要?jiǎng)h除的信息不存在! " << endl;
?? ??? ??? ?return false;
?? ??? ?}
?? ?}
}
//查看學(xué)生信息
bool management::Student_scan()
{
?? ?S_Read_file();
?? ?if (s_sum == 0)
?? ?{
?? ??? ?cout << "暫無(wú)信息!請(qǐng)等待管理人員更新!";
?? ??? ?return false;
?? ?}
?? ?for (int i = 0; i < s_sum; i++)
?? ?{
?? ??? ?s_array[i].s_display();
?? ?}
?? ?return true;
}
//添加圖書(shū)信息
bool management::Book_add()
{
?? ?B_Read_file();
?? ?Book _book;
?? ?cout << "請(qǐng)進(jìn)行信息錄入。按“+”結(jié)束!\n";
?? ?do
?? ?{
?? ??? ?b_array.push_back(_book);
?? ?} while (b_array[b_sum++].B_SetInto());
?? ?b_sum--;
?? ?b_array.pop_back();
?? ?return true;
}
//修改圖書(shū)信息
bool management::Book_mod()
{
?? ?char _b_num[30];
?? ?B_Read_file();
?? ?cout << "請(qǐng)輸入您要修改的圖書(shū)信息的圖書(shū)號(hào)或書(shū)名:";
?? ?cin >> _b_num;
?? ?for (int i = 0; i < b_sum; i++)
?? ?{
?? ??? ?if (b_array[i].B_If_match(_b_num))
?? ??? ?{
?? ??? ??? ?cout << "該圖書(shū)的原信息為:\n";
?? ??? ??? ?b_array[i].b_display();
?? ??? ??? ?cout << "請(qǐng)輸入正確信息! \n";
?? ??? ??? ?b_array[i].B_SetInto();
?? ??? ??? ?b_sum++;??//保持總航線數(shù)不變
?? ??? ??? ?return true;
?? ??? ?}
?? ??? ?if (i == b_sum)
?? ??? ?{
?? ??? ??? ?cout << "抱歉!您要修改的信息不存在! " << endl;
?? ??? ??? ?return false;
?? ??? ?}
?? ??? ?break;
?? ?}
}
//刪除圖書(shū)信息
bool management::Book_del()
{
?? ?char _b_num[15];
?? ?B_Read_file();
?? ?cout << "請(qǐng)輸入您要?jiǎng)h除的圖書(shū)信息的圖書(shū)號(hào):";
?? ?cin >> _b_num;
?? ?for (int i = 0; i < b_sum; i++)
?? ?{
?? ??? ?if (b_array[i].B_If_match(_b_num))
?? ??? ?{
?? ??? ??? ?cout << "該圖書(shū)的原信息為:\n";
?? ??? ??? ?b_array[i].b_display();
?? ??? ??? ?b_array.erase(b_array.begin() + i);
?? ??? ??? ?b_sum--;
?? ??? ??? ?return true;
?? ??? ?}
?? ??? ?if (i == b_sum)
?? ??? ?{
?? ??? ??? ?cout << "抱歉!您要?jiǎng)h除的信息不存在! " << endl;
?? ??? ??? ?return false;
?? ??? ?}
?? ?}
}
//查看圖書(shū)信息
bool management::Book_scan()
{
?? ?B_Read_file();
?? ?if (b_sum == 0)
?? ?{
?? ??? ?cout << "暫無(wú)信息!請(qǐng)等待管理人員更新!";
?? ??? ?return false;
?? ?}
?? ?for (int i = 0; i < b_sum; i++)
?? ?{
?? ??? ?b_array[i].b_display();
?? ?}
?? ?return true;
}
//學(xué)生憑學(xué)號(hào)登錄
bool management::s_login(Student& cp)
{
?? ?char _s_num[15];
?? ?S_Read_file();
?? ?cout << "請(qǐng)輸入您的學(xué)號(hào):";
?? ?cin >> _s_num;
?? ?for (int i = 0; i < s_sum; i++)
?? ?{
?? ??? ?if (s_array[i].S_If_match(_s_num))
?? ??? ?{
?? ??? ??? ?cp=s_array[i];
?? ??? ??? ?cout << "歡迎您," << cp.s_name << "同學(xué)!" << endl;
?? ??? ??? ?S_clear();
?? ??? ??? ?return true;
?? ??? ?}
?? ?}
?? ?S_clear();
?? ?return false;
}
//查看借閱數(shù)數(shù)目
bool management::borrow_scan(Student& cp)
{
?? ?S_Read_file();
?? ?B_Read_file();
?? ?cout << "您已借閱圖書(shū)" << setw(3) << cp.borrow_quantity << "本" << endl;
?? ?for (int i = 0; i < cp.borrow_quantity; i++)
?? ?{
?? ??? ?cout << cp.borrow_books[i] << endl;
?? ?}
?? ?S_clear();
?? ?B_clear();
?? ?return true;
}
//借書(shū)
bool management::borrow_book(Student& cp)
{
?? ?S_Read_file();
?? ?B_Read_file();
?? ?char _b_num[30];
?? ?cout << "請(qǐng)輸入想借圖書(shū)的圖書(shū)號(hào)或書(shū)名:";
?? ?cin >> _b_num;
?? ?for (int i = 0; i < b_sum; i++)
?? ?{
?? ??? ?if (b_array[i].B_If_match(_b_num))
?? ??? ?{
?? ??? ??? ?cout << "該圖書(shū)的信息為:\n";
?? ??? ??? ?b_array[i].b_display();
?? ??? ??? ?b_array[i].b_quantity--;
?? ??? ??? ?if (cp.borrow_quantity > cp.borrow_max - 1)
?? ??? ??? ?{
?? ??? ??? ??? ?cout << "抱歉,您已達(dá)借書(shū)最大上限!" << endl;
?? ??? ??? ??? ?return false;
?? ??? ??? ?}
?? ??? ??? ?strcpy(cp.borrow_books[cp.borrow_quantity++],b_array[i].b_name);
?? ??? ??? ?for (int j = 0; j < s_sum; j++)
?? ??? ??? ?{
?? ??? ??? ??? ?if (s_array[j].S_If_match(cp.s_num))
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?s_array[j]=cp;
?? ??? ??? ??? ??? ?return true;
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?}
?? ??? ?if (i == b_sum - 1)
?? ??? ?{
?? ??? ??? ?cout << "抱歉!您想借的圖書(shū)未收錄! " << endl;
?? ??? ??? ?return false;
?? ??? ?}
?? ?}
}
//還書(shū)
bool management::return_book(Student& cp)
{
?? ?S_Read_file();
?? ?B_Read_file();
?? ?char _b_num[30];
?? ?cout << "請(qǐng)輸入想還圖書(shū)的圖書(shū)號(hào)或書(shū)名:";
?? ?cin >> _b_num;
?? ?for (int i = 0; i < b_sum; i++)
?? ?{
?? ??? ?if (b_array[i].B_If_match(_b_num))
?? ??? ?{
?? ??? ??? ?cout << "該圖書(shū)的信息為:\n";
?? ??? ??? ?b_array[i].b_display();
?? ??? ??? ?b_array[i].b_quantity++;
?? ??? ??? ?for (int k = 0; k < cp.borrow_quantity; k++)
?? ??? ??? ?{
?? ??? ??? ??? ?if (!strcmp(cp.borrow_books[k],b_array[i].b_name))
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?for (int m = k; m < cp.borrow_quantity-1; m++)
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?strcpy(cp.borrow_books[m], cp.borrow_books[m+1]);
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?strcpy(cp.borrow_books[--cp.borrow_quantity], "");
//?? ??? ??? ??? ??? ?cp.borrow_quantity--;
?? ??? ??? ??? ??? ?break;
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ??? ?for (int j = 0; j < s_sum; j++)
?? ??? ??? ?{
?? ??? ??? ??? ?if (s_array[j].S_If_match(cp.s_num))
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?s_array[j] = cp;
?? ??? ??? ??? ??? ?return true;
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?}
?? ??? ?if (i == b_sum)
?? ??? ?{
?? ??? ??? ?cout << "抱歉!您想還的圖書(shū)未收錄! " << endl;
?? ??? ??? ?return false;
?? ??? ?}
?? ?}
}
//工作人員登錄
bool management::Personnel_System()
{
?? ?while (1)
?? ?{
?? ??? ?int menu_options;
?? ??? ?cout << "請(qǐng)輸入登錄密碼:";
?? ??? ?cin >> key;
?? ??? ?if (key == "123456")??//登錄密碼
?? ??? ??? ?while (1)
?? ??? ??? ?{
?? ??? ??? ??? ?cout << endl
?? ??? ??? ??? ??? ?<< "***** ??? ? 主菜單:?? ??? ??? ??? ??? ??? ??? ??? ? ? ? ? ? ?**********" << endl
?? ??? ??? ??? ??? ?<< "***** ? ?工作人員?? ??? ? ? ? ? ? ? ? ??? ?" << endl
?? ??? ??? ??? ??? ?<< "***** ? ?1——添加學(xué)生信息?? ??? ??? ??? ??? ?"
?? ??? ??? ??? ??? ?<< "2——修改學(xué)生信息" << endl
?? ??? ??? ??? ??? ?<< "***** ? ?3——?jiǎng)h除學(xué)生信息?? ??? ??? ??? ??? ?"
?? ??? ??? ??? ??? ?<< "4——查看學(xué)生信息" << endl
?? ??? ??? ??? ??? ?<< endl?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?//區(qū)分學(xué)生和圖書(shū)
?? ??? ??? ??? ??? ?<< "***** ? ?5——添加圖書(shū)信息?? ??? ??? ??? ??? ?"
?? ??? ??? ??? ??? ?<< "6——修改圖書(shū)信息" << endl
?? ??? ??? ??? ??? ?<< "*****?? ? 7——?jiǎng)h除圖書(shū)信息?? ??? ??? ??? ??? ?"
?? ??? ??? ??? ??? ?<< "8——查看圖書(shū)信息" << endl
?? ??? ??? ??? ??? ?<< "***** ? ?9——退出登錄"<<endl
?? ??? ??? ??? ??? ?<< "你需要做什么?(1-9)" << endl;
?? ??? ??? ??? ?cin >> menu_options;
?? ??? ??? ??? ?switch (menu_options)
?? ??? ??? ??? ?{
?? ??? ??? ??? ?case 1:Student_add(); break;
?? ??? ??? ??? ?case 2:Student_mod(); break;
?? ??? ??? ??? ?case 3:Student_del(); break;
?? ??? ??? ??? ?case 4:Student_scan(); break;
?? ??? ??? ??? ?case 5:Book_add(); break;
?? ??? ??? ??? ?case 6:Book_mod(); break;
?? ??? ??? ??? ?case 7:Book_del(); break;
?? ??? ??? ??? ?case 8:Book_scan(); break;
?? ??? ??? ??? ?case 9:return false;
?? ??? ??? ??? ?default:cout << "輸入錯(cuò)誤,請(qǐng)重新選擇" << endl; break;
?? ??? ??? ??? ?}
?? ??? ??? ??? ?if (!(menu_options == 4 || menu_options == 8))
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?cout << "是否確認(rèn)? ? ? ? ?《確認(rèn)/(Y/y)》 ? ?《取消/(N/n)》" << endl;
?? ??? ??? ??? ??? ?char yn;
?? ??? ??? ??? ??? ?do
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?cin >> yn;
?? ??? ??? ??? ??? ?} while (!(yn == 'Y' || yn == 'y' || yn == 'N' || yn == 'n'));
?? ??? ??? ??? ??? ?if (yn == 'Y' || yn == 'y')
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?if (menu_options == 1 || menu_options == 2 || menu_options == 3)
?? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ?S_Save_file();
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?else if (menu_options == 5 || menu_options == 6 || menu_options == 7)
?? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ?B_Save_file();
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?cout << "操作成功";
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?}
?? ??? ??? ??? ?S_clear();
?? ??? ??? ??? ?B_clear();
?? ??? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?cout << "密碼錯(cuò)誤!" << endl;
?? ??? ??? ?continue;
?? ??? ?}
?? ?}
?? ?return true;
}
//學(xué)生登錄
bool management::Student_System()
{
?? ?while (1)
?? ?{
?? ??? ?Student cp;
?? ??? ?bool key = s_login(cp);
?? ??? ?while (key)
?? ??? ?{
?? ??? ??? ?int menu_options;
?? ??? ??? ?cout << "*****?? ? 主菜單:?? ??? ??? ??? ??? ??? ??? ??? ? ? ? ? ? ? ? **********" << endl
?? ??? ??? ??? ?<< "*****?? ? 學(xué)生:?? ??? ??? ??? ??? ??? ??? ?" << endl
?? ??? ??? ??? ?<< "*****?? ? 1——查看借閱數(shù)目" << endl
?? ??? ??? ??? ?<< "*****?? ? 2——借閱圖書(shū)" << endl
?? ??? ??? ??? ?<< "*****?? ? 3——?dú)w還圖書(shū)" << endl
?? ??? ??? ??? ?<< "***** ? ?4——退出登錄" << endl
?? ??? ??? ??? ?<< "你需要做什么?(選擇1-4)" << endl;
?? ??? ??? ?cin >> menu_options;
?? ??? ??? ?switch (menu_options)
?? ??? ??? ?{
?? ??? ??? ?case 1:borrow_scan(cp); break;
?? ??? ??? ?case 2:borrow_book(cp); break;
?? ??? ??? ?case 3:return_book(cp); break;
?? ??? ??? ?case 4:return false;
?? ??? ??? ?}
?? ??? ??? ?if (menu_options == 2 || menu_options == 3)
?? ??? ??? ?{
?? ??? ??? ??? ?cout << "是否確認(rèn)? ? ? ? ?《確認(rèn)/(Y/y)》 ? ?《取消/(N/n)》" << endl;
?? ??? ??? ??? ?char yn;
?? ??? ??? ??? ?do
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?cin >> yn;
?? ??? ??? ??? ?} while (!(yn == 'Y' || yn == 'y' || yn == 'N' || yn == 'n'));
?? ??? ??? ??? ?if (yn == 'Y' || yn == 'y')
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?cout << "操作成功!" << endl;
?? ??? ??? ??? ??? ?S_Save_file();
?? ??? ??? ??? ??? ?B_Save_file();
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ??? ?S_clear();
?? ??? ??? ?B_clear();
?? ??? ?}
?? ??? ?cout << "未找到您的信息!" << endl;
?? ?}
?? ?return true;
}
//界面初始化函數(shù)
void management::login_init()
{
?? ?system("cls");
?? ?cout << "\n>>>>>>>>>>歡迎進(jìn)入圖書(shū)管理系統(tǒng)<<<<<<<<<<" << endl
?? ??? ?<< "請(qǐng)輸入您的登錄方式" << endl
?? ??? ?<< "1——工作人員(需要認(rèn)證)?? ?2——學(xué)生 3——退出系統(tǒng)" << endl;
}
//主函數(shù)
int main()
{
?? ?management xiangnan;
?? ?//若文件不存在,則新建文件
?? ?//存放學(xué)生信息
?? ?ofstream Student_Information("Student_Information.txt", ios::app);
?? ?if (!Student_Information)
?? ?{
?? ??? ?cerr << "文件\"flight information.dat\"無(wú)法打開(kāi)!\n";
?? ??? ?exit(1);
?? ?}
?? ?Student_Information.close();
?? ?//存放圖書(shū)信息
?? ?ofstream Book_Information("Book_Information.txt", ios::app);
?? ?if (!Book_Information)
?? ?{
?? ??? ?cerr << "文件\"flight information.dat\"無(wú)法打開(kāi)!\n";
?? ??? ?exit(1);
?? ?}
?? ?Book_Information.close();
?? ?int dlry;???//登陸人員
?? ?while (1)
?? ?{
?? ??? ?xiangnan.login_init();???//界面初始化
?? ??? ?cin >> dlry;
?? ??? ?if (dlry == 1)
?? ??? ?{
?? ??? ??? ?xiangnan.Personnel_System();
?? ??? ?}
?? ??? ?else if (dlry == 2)
?? ??? ?{
?? ??? ??? ?xiangnan.Student_System();
?? ??? ?}
?? ??? ?else if (dlry == 3)
?? ??? ?{
?? ??? ??? ?return 0;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?cout << "輸入錯(cuò)誤,請(qǐng)重新選擇!" << endl;
?? ??? ?}
?? ?}
?? ?return 0;
}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- C++實(shí)現(xiàn)簡(jiǎn)單的圖書(shū)管理系統(tǒng)
- C++實(shí)現(xiàn)圖書(shū)管理系統(tǒng)
- C++實(shí)現(xiàn)圖書(shū)管理系統(tǒng)課程設(shè)計(jì)
- C++實(shí)現(xiàn)圖書(shū)管理系統(tǒng)源碼
- C++編寫(xiě)實(shí)現(xiàn)圖書(shū)管理系統(tǒng)
- C++實(shí)現(xiàn)圖書(shū)館管理系統(tǒng)
- C++利用鏈表實(shí)現(xiàn)圖書(shū)信息管理系統(tǒng)
- C++順序表實(shí)現(xiàn)圖書(shū)管理系統(tǒng)
- C++實(shí)現(xiàn)圖書(shū)管理系統(tǒng)最新版
- C++實(shí)現(xiàn)簡(jiǎn)單版圖書(shū)管理系統(tǒng)
相關(guān)文章
C語(yǔ)言實(shí)現(xiàn)BMP格式圖片轉(zhuǎn)化為灰度
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)BMP格式圖片轉(zhuǎn)化為灰度,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-10-10
C語(yǔ)言sizeof和strlen的指針和數(shù)組面試題詳解
strlen是函數(shù),字符串長(zhǎng)度,不包括停止符。而sizeof則是內(nèi)存塊的大小,包括停止符。數(shù)組是一種數(shù)據(jù)類型,數(shù)據(jù)類型的本質(zhì)就是固定大小,內(nèi)存塊的別名??梢杂胹izeof()一般都是數(shù)據(jù)類型2022-04-04
C++實(shí)現(xiàn)校園運(yùn)動(dòng)會(huì)報(bào)名系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)校園運(yùn)動(dòng)會(huì)報(bào)名系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-10-10

