package com.book.main;
import java.util.Scanner;
import com.book.model.Book;
import com.book.model.Customer;
import com.book.model.Member;
import com.book.tools.BookTools;
import com.book.tools.CustomerTools;
public class MainFrame {
private int option = -1;
private static Scanner sc = new Scanner(System.in);
private String reStr;
private int index = -1;
public static void main(String[] args) {
Book java = new Book("java", "王长青", "清华大学出版社", "图书备注", 50f, 100);
Book cpp = new Book("c++", "谭浩强", "北京邮电出版社", "图书备注2", 45f, 100);
BookTools.getInstance().addBook(java);
BookTools.getInstance().addBook(cpp);
new MainFrame().run();// 运行
sc.close();
}
/**
* 图书管理
*/
public void bookManager() {
boolean flag = true;
do {
System.out.println("******************图书信息管理******************");
System.out.println("\t 1.添加图书");
System.out.println("\t 2.删除图书");
System.out.println("\t 3.修改图书");
System.out.println("\t 4.查询图书");
System.out.println("\t 5.显示所有图书");
System.out.println("\t 0.返回上级菜单");
System.out.println("请输入0-5之间的数字进行选择:");
option = sc.nextInt();
switch (option) {
case 1:// 添加图书
do {
System.out.println("**********添加图书**********");
System.out.println("请输入书名、作者、出版社、备注、单价以及数量: ");
String bookName = sc.next();
String author = sc.next();
String pub = sc.next();
String remark = sc.next();
float price = sc.nextFloat();
int bookNum = sc.nextInt();
Book book = new Book(bookName, author, pub, remark, price, bookNum);
System.out.println(book);
BookTools.getInstance().addBook(book);
System.out.println("是否继续添加?(y/n)");
reStr = sc.next();
if (reStr.equals("n"))
break;
} while (true);
break;
case 2:// 删除图书
do {
System.out.println("**********删除图书**********");
System.out.println("\t 请输入待删除的书名:");
reStr = sc.next();
index = BookTools.getInstance().findBook(reStr);
if (index == -1) {
System.out.println("抱歉,未找到该书!");
} else {
BookTools.getInstance().deleteBook(index);
System.out.println("该书已删除");
}
System.out.println("是否继续删除图书?(y/n)");
reStr = sc.next();
if (reStr.equalsIgnoreCase("y"))
continue;
else if (reStr.equalsIgnoreCase("n"))
break;
} while (true);
break;
case 3:// 修改图书
System.out.println("**********修改图书**********");
System.out.println("请输入待修改的书名:");
reStr = sc.next();
index = BookTools.getInstance().findBook(reStr);
if (index == -1) {
System.out.println("抱歉,未找到该书!");
} else {
do {
System.out.println("请选择待修改的图书属性:");
System.out.println("\t name.修改书名");
System.out.println("\t author.修改作者");
System.out.println("\t pub.修改出版社");
System.out.println("\t money.修改单价");
System.out.println("\t amount.修改数量");
System.out.println("\t remark.修改备注");
String fieldName = sc.nextLine();
sc.nextLine();
System.out.println("请输入要修改的值:");
reStr = sc.nextLine();
BookTools.getInstance().updateBook(index, fieldName, reStr);
System.out.println("是否继续修改该图书?(y/n)");
reStr = sc.next();
if (reStr.equalsIgnoreCase("y")) {
continue;
} else if (reStr.equalsIgnoreCase("n")) {
break;
}
} while (true);
}
break;
case 4:// 查询图书
do {
System.out.println("请输入查询选项:");
System.out.println("1.按书名查询");
System.out.println("2.按出版社查询");
System.out.println("3.按作者查询");
System.out.println("4.按价格查询");
option = sc.nextInt();
String reString;
switch (option) {
case 1:// 书名查询
System.out.println("请输入待查书名:");
reString = sc.next();
BookTools.getInstance().queryBook(1, reString);
break;
case 2:// 出版社查询
System.out.println("请输入待查出版社");
reString = sc.next();
BookTools.getInstance().queryBook(2, reString);
break;
case 3:// 作者查询
System.out.println("请输入待查作者:");
reString = sc.next();
BookTools.getInstance().queryBook(3, reString);
break;
case 4:// 价格查询
BookTools.getInstance().queryBook(4, null);
break;
default:
break;
}
System.out.println("是否继续查询?(y/n)");
reStr = sc.next();
if (reStr.equalsIgnoreCase("y"))
continue;
else if (reStr.equalsIgnoreCase("n"))
break;
} while (true);
break;
case 5:// 显示所有图书
BookTools.getInstance().booksInfo();
break;
case 0:// 返回上一级菜单
flag = false;
break;
default:
break;
}
} while (flag);
}
/**
* 客户管理
*/
public void customerManager() {
boolean flag = true;
do {
System.out.println("******************客户管理******************");
System.out.println("\t 1.注册会员");
System.out.println("\t 3.修改客户信息");
System.out.println("\t 4.查找客户");
System.out.println("\t 5.显示所有会员");
System.out.println("\t 6.会员充值");
System.out.println("\t 0.返回上级菜单");
System.out.println("请输入0-6之间的整数进行选择:");
index = sc.nextInt();
switch (index) {
case 1:// 注册客户
do {
System.out.println("请输入客户姓名:");
String name = sc.next();
System.out.println("请输入客户性别:");
String gender = sc.next();
System.out.println("请输入充值金额:");
double balance = sc.nextDouble();
String id = "v" + generateID();// 生成ID
Member member = new Member(id, name, gender, balance);
System.out.println(member.toString());
CustomerTools.getInstance().add(member);
System.out.println("是否继续注册会员?(y/n)");
reStr = sc.next();
if (reStr.equalsIgnoreCase("y"))
continue;
else if (reStr.equalsIgnoreCase("n")) {
break;
}
} while (true);
break;
case 3:// 修改客户
System.out.println("请输入待修改客户ID");
reStr = sc.next();
index = CustomerTools.getInstance().findCustomer(reStr);
if (index >= 0) {
CustomerTools.getInstance().modifyCustomer(index);
} else if (index == -1) {
System.out.println("抱歉,未找到该客户!");
}
break;
case 4:// 查找客户
System.out.println("请输入待查找客户ID");
reStr = sc.next();
index = CustomerTools.getInstance().findCustomer(reStr);
if (index == -1) {
System.out.println("抱歉,未找到该客户!");
} else {
CustomerTools.getInstance().select(index);
}
break;
case 5:// 显示所有会员
CustomerTools.getInstance().showAllInfo();
break;
case 6:// 会员充值
System.out.println("请输入待充值会员ID");
reStr = sc.next();
index = CustomerTools.getInstance().findCustomer(reStr);
if (index >= 0) {
CustomerTools.getInstance().charge(index);
} else if (index == -1) {
System.out.println("抱歉,未找到该客户!");
}
break;
case 0:
flag = false;
break;
default:
break;
}
} while (flag);
}
/**
* 租赁管理
*/
public void rentalManager() {
boolean flag = true
知识林
- 粉丝: 106
- 资源: 13
最新资源
- 优质订单车后台管理系统:支持Excel订单导入功能,强大稳定且功能齐全,订单车后台管理系统,自己开发的,基本功能齐全,支持excel订单导入功能, ,核心关键词:订单车后台管理系统; 自研发; 基本功
- libidn-1.28-4.el7.x64-86.rpm.tar.gz
- 精准称重:C#源码下的地磅程序与过磅软件技术解析,称重系统,过磅软件,地磅程序,c#源码 ,称重系统; 过磅软件; 地磅程序; C#源码; 程序开发; 代码管理,"C#源码:地磅程序与过磅软件集成称重
- libiec61883-1.2.0-10.el7.x64-86.rpm.tar.gz
- 基于MATLAB的神经网络实战案例分析集(含源码):BP神经网络数据分类与语音特征信号识别、非线性系统建模与非线性函数拟合等案例详解 ,【matlab神经网络30个案例分析及源码】 案例1 BP神
- libiec61883-devel-1.2.0-10.el7.x64-86.rpm.tar.gz
- MCGS与组态王停车库管理模拟仿真系统:智能化监控与高效管理解决方案,MCGS停车库管理模拟仿真 组态王停车库管理模拟仿真 停车库管理系统 ,核心关键词:MCGS停车库管理;组态王停车库管理模
- libiec61883-utils-1.2.0-10.el7.x64-86.rpm.tar.gz
- 欧姆龙CP1H+CIF11与英威腾GD变频器Modbus通讯全功能实现:反应灵敏,通讯稳定可靠,含原创程序、注释及接线手册等全套支持 ,欧姆龙CP1H+CIF11与英威腾GD变频器modbus通讯功能
- libieee1284-0.2.11-15.el7.x64-86.rpm.tar.gz
- libieee1284-devel-0.2.11-15.el7.x64-86.rpm.tar.gz
- 基于模拟量信号的变频器电机频率调控:理解编程思维的核心与电机控制流程,变频器的频率是通过模拟量0-10V信号进行调节,两台电机具有相同的控制方式,每按一次频率递增按钮,则增加1Hz频率,每按一次递减按
- 基于Python的活动管理系统基础教程
- libieee1284-python-0.2.11-15.el7.x64-86.rpm.tar.gz
- Labview用户登录模块:加密解密用户密码,新增用户功能,保障应用安全便捷访问,labview 用户登录模块,用户密码加密解密 新增用户功能,可方便应用 ,核心关键词:LabView; 用户登录
- libimobiledevice-1.2.0-1.el7.x64-86.rpm.tar.gz
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈