模拟订房、退房、打印所有房间状态等功能
2.主程序import java.util.Scanner;
public class HotelMgtSystem {
public static void main(String[] args) {
//创建酒店对象
Hotel hotel = new Hotel();
//打印房间状态
//hotel.print();
while(true) {
System.out.println("欢迎使用酒店管理系统");
System.out.println("请输入对应的功能编号:[1]查看房间列表[2]订房[3]退房[0]退出系统");
Scanner s = new Scanner(System.in);
System.out.print("请输入功能编号:");
int i = s.nextInt();
if (i == 1) {
hotel.print();
} else if (i == 2) {
System.out.print("请输入房间编号:");
int roomNum = s.nextInt();
hotel.order(roomNum);
} else if (i == 3) {
System.out.print("请输入房间编号:");
int roomNum = s.nextInt();
hotel.exit(roomNum);
} else if (i == 0) {
System.out.println("再见!欢迎下次再来");
return;
} else {
System.out.println("输入不正确!");
return;
}
}
}
}
3.房间类(部分代码)
//房间号
private int no;
//房间类型
private String type;
//房间状态
private boolean status;
//构造方法
public Home() {
}
public Home(int no, String type, boolean status) {
this.no = no;
this.type = type;
this.status = status;
}
4.酒店类
public class Hotel {
//二维数组,模拟大厦所有房间
private Home[][] homes;
//构造方法
public Hotel() {
//动态初始化
this.homes = new Home[3][10]; //3行10列。3层楼,每层10个房间。
//创建30个对象放进数组中。怎么放?二维数组遍历
for(int i=0;i
5.代码还有需要修改的地方 


