酒店管理系统JAVA代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
import java.util.Scanner;
import org.omg.CORBA.PUBLIC_MEMBER;
public class jiudian {
static String[][] rooms ;
public static void main(String[] args) {
rooms = new String[8][8];
for (int i = 0; i < rooms.length; i++) {
for (int j = 0; j < rooms[i].length; j++) {
rooms[i][j] = "NULL";
}
}
String command = "";
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("请输入命令:");
command = scanner.nextLine();
if(command.equals("search")){
searchRoom();
}else if (command.equals("in")) {
System.out.println("请输入您需要入住的房间号:");
String roomIDString = scanner.nextLine();
int roomID = Integer.parseInt(roomIDString);
System.out.println("请输入您的姓名:");
String userName = scanner.nextLine();
inRoom(roomID,userName);
}else if(command.equals("out")){
System.out.println("请输入您需要退订的房间号:");
String roomIDString = scanner.nextLine();
int roomID = Integer.parseInt(roomIDString);
outRoom(roomID);
}else if (command.equals("quit")) {
System.out.println("欢迎再次使用");
System.exit(0);
}else {
System.out.println("输入命令有误,请重新输入!");
}
}
}
public static void searchRoom(){
for (int i = 0; i < rooms.length; i++) {
//输出房间号
for (int j = 0; j < rooms[i].length; j++) {
System.out.print((i+1)+"0"+(j+1)+"\t");
}
System.out.println();
//输出房间情况
for (int j = 0; j < rooms[i].length; j++) {
System.out.print(rooms[i][j]+"\t");
}
System.out.println();
}
}
public static void inRoom(int roomID , String userName){ if (isRoomNull(roomID)) {
//房间为空
//房间状态:NULL-->userName
int i = roomID/100-1;
int j = roomID%100-1;
rooms[i][j] =userName;
System.out.println(userName+"成功入住"+roomID);
}else {
//房间不为空
System.out.println("该房间已经有人,请重新选择!");
}
}
public static void outRoom(int roomID){
if (isRoomNull(roomID)) {
//房间为空
System.out.println("房间为空无需退房");
}else {
//房间不为空
//房间状态:userName -->NULL
int i = roomID/100-1;
int j = roomID%100-1;
rooms[i][j] ="NULL";
System.out.println(roomID+"退房成功!");
}
}
private static boolean isRoomNull(int roomID) { //801 -->i=7 j=0 -->rooms[7][0]
int i = roomID/100-1;
int j = roomID%100-1;
if (rooms[i][j].equals("NULL")) {
return true;
}else {
return false;
}
}
}