#include "process.h"
#include <iostream>
#include <exception>
#include <Windows.h>
#include <algorithm>
//默认构造函数--初始化
Process::Process()
{
fineBase = 0;
maxLendDays = 7;
maxLendNumStu = 5;
maxLendNumTea = 10;
valid = false;
}
//是否有效
bool Process::getValid()
{
return valid;
}
//读取所有文件
void Process::readAllFiles()
{
readBookFile();
readPeopleFile();
readBorrowFile();
readParameterFile();
}
//所有操作
void Process::allMenu()
{
system("cls");
cout << endl << "---------------图书信息管理系统---------------" << endl;
cout << "1. 图书管理" << endl;
cout << "2. 借阅管理" << endl;
cout << "3. 读者管理" << endl;
cout << "4. 统计分析" << endl;
cout << "5. 系统参数" << endl;
cout << "6. 关于我们" << endl;
cout << "7. 退出系统" << endl;
cout << "----------------------------------------------" << endl;
cout << "请选择功能:";
char choice;
cin >> choice;
switch (choice)
{
case '1':
if (!input())
{
cout << "密码错误!" << endl;
system("pause");
return allMenu();
}
manageBooks();
break;
case '2':
manageBorrows();
break;
case '3':
if (!input())
{
cout << "密码错误!" << endl;
system("pause");
return allMenu();
}
managePeople();
break;
case '4':
analysis();
break;
case '5':
if (!input())
{
cout << "密码错误!" << endl;
system("pause");
return allMenu();
}
setParameters();
break;
case '6':
about();
break;
case '7':
exit(0);
default:
cout << "输入错误!" << endl;
char buf[1024];
fgets(buf, 1024, stdin);
system("pause");
return allMenu();
}
cout << endl;
system("pause");
allMenu();
}
//图书信息管理
void Process::manageBooks()
{
char buf[1024];
//fgets(buf, 1024, stdin);
system("cls");
cout << endl << "---------------图书管理---------------" << endl;
cout << "1. 添加图书" << endl;
cout << "2. 删除图书" << endl;
cout << "3. 修改图书" << endl;
cout << "4. 查询图书" << endl;
cout << "5. 返回上层菜单" << endl;
cout << "------------------------------------------" << endl;
cout << "请选择功能:";
char choice;
cin >> choice;
switch (choice)
{
case '1':
if (!addBook())
{
cout << endl << "已成功添加。" << endl;
}
else
{
cout << endl << "已取消添加。" << endl;
}
break;
case '2':
deleteBook();
break;
case '3':
reviseBook();
break;
case '4':
searchBook();
break;
case '5':
return allMenu();
default:
cout << endl << "输入有误!" << endl;
fgets(buf, 1024, stdin);
break;
}
cout << endl;
system("pause");
manageBooks();
}
//借阅管理
void Process::manageBorrows()
{
system("cls");
cout << endl << "---------------图书管理---------------" << endl;
cout << "1. 借书" << endl;
cout << "2. 还书" << endl;
cout << "3. 续借" << endl;
cout << "4. 返回上层" << endl;
cout << "------------------------------------------" << endl;
cout << "请选择功能:";
char choice;
cin >> choice;
switch (choice)
{
case '1':
addBorrow();
break;
case '2':
deleteBorrow();
break;
case '3':
renewBorrow();
break;
case '4':
return allMenu();
default:
cout << endl << "输入有误!" << endl;
char buf[1024];
fgets(buf, 1024, stdin);
break;
}
cout << endl;
system("pause");
manageBorrows();
}
//读者管理
void Process::managePeople()
{
system("cls");
cout << endl << "-----------------读者管理-----------------" << endl;
cout << "1. 读者录入" << endl;
cout << "2. 读者挂失" << endl;
cout << "3. 读者注销" << endl;
cout << "4. 读者查询" << endl;
cout << "5. 设定教师的可借书数量" << endl;
cout << "6. 设定学生的可借书数量" << endl;
cout << "7. 返回上层菜单" << endl;
cout << "------------------------------------------" << endl;
cout << "请选择功能:";
char choice;
cin >> choice;
switch (choice)
{
case '1':
addPeople();
break;
case '2':
losePeople();
break;
case '3':
deletePeople();
break;
case '4':
searchPeople();
break;
case '5':
setMaxLendNumTea();
break;
case '6':
setMaxLendNumStu();
break;
case '7':
return allMenu();
default:
cout << endl << "输入有误!" << endl;
char buf[1024];
fgets(buf, 1024, stdin);
break;
}
cout << endl;
system("pause");
fflush(stdin);
managePeople();
}
//统计分析
void Process::analysis()
{
system("cls");
cout << endl << "-----------------统计分析-----------------" << endl;
cout << "1. 借阅排行榜" << endl;
cout << "2. 图书统计" << endl;
cout << "3. 到期未还书信息" << endl;
cout << "4. 返回上层菜单" << endl;
cout << "------------------------------------------" << endl;
cout << "请选择功能:";
char choice;
cin >> choice;
switch (choice)
{
case '1':
rankBoard();
break;
case '2':
statusAnalysis();
break;
case '3':
allNotReturning();
break;
case '4':
return allMenu();
default:
cout << endl << "输入有误!" << endl;
char buf[1024];
fgets(buf, 1024, stdin);
break;
}
cout << endl;
system("pause");
analysis();
}
//系统参数设置
void Process::setParameters()
{
system("cls");
cout << endl << "---------------系统参数设置---------------" << endl;
cout << "1. 设置罚款金额基数" << endl;
cout << "2. 设置最多借阅天数" << endl;
cout << "3. 返回上层菜单" << endl;
cout << "------------------------------------------" << endl;
cout << "请选择功能:";
char choice;
cin >> choice;
switch (choice) {
case '1':
setFineBase();
break;
case '2':
setMaxLendDays();
break;
case '3':
return allMenu();
default:
cout << endl << "输入有误!" << endl;
char buf[1024];
fgets(buf, 1024, stdin);
break;
}
cout << endl;
system("pause");
setParameters();
}
//关于
void Process::about()
{
system("cls");
cout << endl << "---------------关于---------------" << endl;
cout << "程序名称:南昌大学图书信息管理系统" << endl;
cout << "版本:1.1.2" << endl;
cout << "完成时间:2019年6月13日" << endl;
cout << "姓名:简程涛" << endl;
cout << "班级:软件工程1808班" << endl;
cout << "学号:8002118220" << endl;
cout << "----------------------------------" << endl;
system("pause");
allMenu();
}
//日期是否有效
bool Process::isValidDate(string str) const
{
//年月日之间没有'-',不合法
if (str.size() != 10 || str[4] != '-' || str[7] != '-')
{
return false;
}
int year = getYear(str);
//年份在2019以后,不合法
if (year > 2019)
{
return false;
}
int month = getMonth(str);
//月份不合法
if (month < 1 || month > 12)
{
return false;
}
int day = getDay(str);
//日不合法
if (day < 1 || day > 31)
{
return false;
}
//1,3,5,7,8,10,12不是31天,不合法
if (day == 31)
{
if (month != 1 && month != 3 && month != 5 && month != 7 && month != 8 && month != 10 && month != 12)
{
return false;
}
}
//2月有30天不合法
else if (day == 30)
{
if (month == 2)
{
return false;
}
}
//非闰年2月29天,不合法
else if (day == 29 && month == 2)
{
if (!isLeap(year))
{
return false;
}
}
return true;
}
//判断闰年
bool Process::isLeap(int year) const
{
//闰年判断条件
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
{
return true;
}
else
{
return false;
}
}
//获得年
int Process::getYear(string str) const
{
if (str.size() != 10 || str[4] != '-' || str[7] != '-')
{
return 0;
}
int year = 0;
for (int i = 0; i <= 3; i++)
{
if (str[i] >= '0' && str[i] <= '9')
{
year = year * 10 + str[i] - '0';
}
else
{
return 0;
}
}
return year;
}
//获得月
int Process::getMonth(string str) const
{
if (str.size() != 10 || str[4] != '-' || str[7] != '-')
{
return 0;
}
int month = 0;
for (int i = 5; i <= 6; i++)
{
if (str[i] >= '0' && str[i] <= '9')
{
month = month * 10 + str[i] - '0';
}
else
{
return 0;
}
}
qq_52051345
- 粉丝: 67
- 资源: 1
最新资源
- 【创新无忧】基于豪猪优化算法CPO优化相关向量机RVM实现数据多输入单输出回归预测附matlab代码.rar
- 【创新无忧】基于黑翅鸢算法BKA优化广义神经网络GRNN实现电机故障诊断附matlab代码.rar
- 【创新无忧】基于黑翅鸢算法BKA优化极限学习机ELM实现乳腺肿瘤诊断附matlab代码.rar
- 【创新无忧】基于黑猩猩优化算法Chimp优化广义神经网络GRNN实现电机故障诊断附matlab代码.rar
- 【创新无忧】基于黑猩猩优化算法Chimp优化广义神经网络GRNN实现光伏预测附matlab代码.rar
- 【创新无忧】基于黑翅鸢算法BKA优化极限学习机KELM实现故障诊断附matlab代码.rar
- 【创新无忧】基于黑猩猩优化算法Chimp优化广义神经网络GRNN实现数据回归预测附matlab代码.rar
- 【创新无忧】基于黑猩猩优化算法Chimp优化极限学习机ELM实现乳腺肿瘤诊断附matlab代码.rar
- 【创新无忧】基于黑猩猩优化算法Chimp优化极限学习机KELM实现故障诊断附matlab代码.rar
- 【创新无忧】基于花朵授粉优化算法FPA优化广义神经网络GRNN实现电机故障诊断附matlab代码.rar
- 【创新无忧】基于黑猩猩优化算法Chimp优化相关向量机RVM实现北半球光伏数据预测附matlab代码.rar
- 【创新无忧】基于黑猩猩优化算法Chimp优化相关向量机RVM实现数据多输入单输出回归预测附matlab代码.rar
- 【创新无忧】基于花朵授粉优化算法FPA优化广义神经网络GRNN实现数据回归预测附matlab代码.rar
- 【创新无忧】基于花朵授粉优化算法FPA优化广义神经网络GRNN实现光伏预测附matlab代码.rar
- 【创新无忧】基于花朵授粉优化算法FPA优化极限学习机ELM实现乳腺肿瘤诊断附matlab代码.rar
- 【创新无忧】基于花朵授粉优化算法FPA优化相关向量机RVM实现数据多输入单输出回归预测附matlab代码.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈