酒店管理系统JAVA代码

时间:2022-07-11 21:11:15 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。
酒店管理系统



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"); }

页脚内容

1


酒店管理系统







}

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; }

页脚内容

2


酒店管理系统





}

}



页脚内容

3


本文来源:https://www.wddqw.com/doc/6dae54b92ec58bd63186bceb19e8b8f67d1cef15.html