酒店管理系统
2022/1/11 23:35:27
本文主要是介绍酒店管理系统,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
文章目录
- 酒店管理系统
- 一、房间信息初始化
- 二、实现功能
- 1.主方法
- 2.功能查房
- 3.订房功能
- 4.退房功能
- 5.退出系统
- 总结
酒店管理系统
提示:以下是本篇文章正文内容,下面案例可供参考
一、房间信息初始化
static Scanner sc = new Scanner(System.in); static int[][] roomNum = new int[5][5]; static String[][] roomMask = new String[5][5]; static String[][] pasName=new String[5][5]; //初始化房间信息 public static void Room() { for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 5; j++) { roomMask[i - 1][j - 1] = "empty"; } }
二、实现功能
1.主方法
选择while循环可以一直进行操作,使用switch选择做多分支选择
public static void main(String[] args) { Room(); while (true) { System.out.println("==========欢迎来到天天酒店!==========\n1.查房\t2.订房\t3.退房\t4.退出系统"); System.out.print("请输入数字,选择需要的服务:"); int Input = sc.nextInt(); //判断数字,进入不同的子系统 switch (Input) { case 1: select(); break; case 2: reserve(); break; case 3: out(); break; case 4: outSystem(); break; default: System.out.println("请输入正确的数字"); break; } } }
2.功能查房
通过键盘的输入信息,完成查房功能,需要在主方法中调用查房方法
public static void select() { System.out.println("进入查房功能,正在为您查询房间信息……"); //查询操作 for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 5; j++) { roomNum[i - 1][j - 1] = i * 100 + j; System.out.print(roomNum[i - 1][j - 1]+ "\t\t"); } System.out.println(); for (int j = 1; j <= 5; j++) { System.out.print(roomMask[i - 1][j - 1] + "\t"); } System.out.println(); System.out.println("======================================"); } }
3.订房功能
通过键盘输入预定信息,注意判断房间是否预定,同时需要更新房间信息,完成查房功能,需要在主方法中调用订房方法。此处入住后,注意再使用查询房间信息时,需要做到已入住信息的隐私,设置pasName
private static void reserve() { System.out.println("进入订房房功能……"); System.out.println("请输入您要预定的房间号:"); int reRoom = sc.nextInt(); //判断是否输入有效 if (reRoom > 505 || reRoom < 101) { System.out.println("对不起,您输入的房间号码错误。"); } else { //判断预订的房间状态是否入住 if ("empty".equals(roomMask[reRoom / 100 - 1][reRoom % 10 - 1])) { //可以入住 System.out.println("请输入您的姓名:"); String name = sc.next(); //将姓存入roomMask,将姓名存入pasName roomMask[reRoom / 100 - 1][reRoom % 10 - 1] = name.charAt(0)+"先生"; pasName[reRoom / 100 - 1][reRoom % 10 - 1]=name; System.out.println("请输入您的身份证号:"); int IDCard = sc.nextInt(); System.out.println("请输入您的手机号:"); int phone = sc.nextInt(); System.out.println("恭喜您!" + name + "先生,您已成功预定" + reRoom + "房间"); System.out.println( "请带好身份证: "+IDCard+"到前台报手机号: " + phone + "办理入住"); } else { System.out.println("对不起,该房间已被预定。"); } } }
4.退房功能
通过键盘输入预定信息,注意判断房间是否预定,退订信息是否正确,完成后需要更新房间信息,完成退房功能,需要在主方法中调用退房方法。
private static void out() { System.out.println("进入退房功能……"); System.out.println("请输入您要退定的房间号:"); int outRoom = sc.nextInt(); //判断是否输入有效 if (outRoom > 505 || outRoom < 101) { System.out.println("对不起,您输入的房间号码错误。"); } else { //判断退订的房间状态是否入住 if (!"empty".equals(roomMask[outRoom / 100 - 1][outRoom % 10 - 1])) { //可以退房 System.out.println("请输入您的姓名:"); String name = sc.next(); //判定名字是否正确 if (name.equals(pasName[outRoom / 100 - 1][outRoom % 10 - 1])) { System.out.println(name + "先生,您已成功完成" + outRoom + "房间的退订,欢迎下次光临!"); roomMask[outRoom / 100 - 1][outRoom % 10 - 1] = "empty"; } else { System.out.println("对不起,您的信息与房间入住信息不匹配,无法完成退订。"); } }else{ System.out.println("对不起,您没有预定过该房间"); } } }
5.退出系统
通过键盘输入完成退出系统。这里加了一个弹窗选择。
private static void outSystem(){ System.out.println("这是退出系统"); int result = JOptionPane.showConfirmDialog(null, "您真的要离开我嘛?", "枫林晚酒店", JOptionPane.YES_NO_OPTION); /*** 是: 0 * 否: 1 * ×: -1 */ if (result==1 || result == -1) { System.out.println("风景太美,不忍离别吧!"); }else { System.out.println("欢迎下次光临"); System.exit(0); } }
总结
完成每个功能的基本操作,后续需要加入数据库来存储信息,进一步完善和修改系统的功能。
这篇关于酒店管理系统的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)