数组小案例:使用数组实现酒店预订系统
public class Demo5 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("酒店预订系统");
Hotel h = new Hotel();
h.print();
while(true) {
System.out.println("请输入房间编号:");
int num = sc.nextInt();
h.order(num);
h.print();
}
}
}
class Room {
/**
* 房间号
*/
private int no;
/**
* 房间类型
*/
private String type;
/**
* 房间是否被预订
*/
private boolean isReserved;
public Room(int no, String type, boolean isReserved) {
super();
this.no = no;
this.type = type;
this.isReserved = isReserved;
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public boolean isReserved() {
return isReserved;
}
publ