A.酒店客房管理系统(命令行版本)
* 1.search是查询酒店房间状态的命令。
* 2.in是有客人入住的命令,此时需要提供入住的客户名字和房间号。
* 3.out是客户退房的命令,此时需要提供退房的房间号。
* 4.exit是退出命令。
* 提示:房间状态用一个String类型的二维数组表示即可,里面的元素初始值为" EMPTY".
View Code JAVA
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | /* A.酒店客房管理系统(命令行版本) * 1.search是查询酒店房间状态的命令。 * 2.in是有客人入住的命令,此时需要提供入住的客户名字和房间号。 * 3.out是客户退房的命令,此时需要提供退房的房间号。 * 4.exit是退出命令。 * 提示:房间状态用一个String类型的二维数组表示即可,里面的元素初始值为" EMPTY". */ import java.util.*; public class HomeWork4_3 { public static void main(String[] args) { Scanner sc = new Scanner (System.in); String arr[][] = new String[81][2]; int room[]= new int[81]; int m=1; for(int i=0;i<81;i++) { room[i]=m+(i/9+1)*100; m++; arr[i][0]=""+room[i]; arr[i][1]="EMPTY"; if(m>9) m=1; } while(true){ System.out.println("Please input your commond:"); String com = sc.next(); if("search".equals(com)) { int n=0; System.out.println("————————————欢迎访问 laycher.cn—————————————"); for(int i = 0;i<81;i++) { System.out.print(arr[i][0]+"\t"); m++; if(m>9) { m=1; System.out.println(); for(int j=0;j<9;j++) { System.out.print(arr[n][1]+"\t"); n++; } System.out.println(); } } System.out.println(); } else if("in".equals(com)) { System.out.println("Please input the customer's name and his room number:\n(For Example:Laycher 202)"); String cus = sc.next(); String num = sc.next(); int i=0; while(true) { if(arr[i][0].equals(num)) { if("EMPTY".equals(arr[i][1])) { arr[i][1]=cus; System.out.println("Your command succeed!\n"); break; } else { System.out.println("This room already have customer!\nPlease try another room.\n"); break; } } else { i++; if(i>=81) { System.out.println("No This Room!\n"); break; } } } } else if("out".equals(com)) { System.out.println("Please input the customer's room number:\n(For Example:202)"); String num = sc.next(); int i=0; while(true){ if (num.equals(arr[i][0])) { if("EMPTY".equals(arr[i][1])) { System.out.println("This room is EMPTY.No Customer!\nPlease Check!\n"); break; } else { arr[i][1]="EMPTY"; System.out.println("Your command succeed!\n"); break; } } else { i++; if(i>=81) { System.out.println("No This Room!\n"); break; } } } } else if("exit".equals(com)) { return; System.out.println("————————————欢迎访问 laycher.cn—————————————"); } else { System.out.println("Input Error!Please input again!\n"); } } } } |
>> 若为原创,转载请注明: 转载自Laycher's Blog
>> 本文链接地址: 酒店客房管理系统(命令行版本)
>> 订阅本站: http://feed.feedsky.com/laycher