动力节点-JavaSE零基础-酒店管理系统(简单版)

 1.每一个房间Room应该有:房间编号、房间类型、房间是否空闲

 2.系统对外提供的功能:

        2.1 可以预定房间

        2.2 可以退房

        2.3 可以查看所有房间的状态

package com.array2;
import java.util.Scanner;
/*
    酒店信息管理系统
 */
public class HotelTest {
    public static void main(String[] args) {
        //创建房间对象,初始化此酒店房间信息
        Room[][] rooms ={
                {new Room(101,"单人间","空"),new Room(102,"单人间","空")},
                {new Room(201,"双人间","空"),new Room(202,"双人间","空")},
                {new Room(301,"豪华间","空"),new Room(302,"豪华间","空")}
        };
        //创建前台对象
        stage s1 = new stage(rooms);

        Scanner num = new Scanner(System.in);
        int preId = num.nextInt();
        //前台预定
        s1.showPre(preId);
        //前台退房
        s1.showExit(preId);
        //酒店实时状态
        s1.showMenu();
    }
}

//酒店前台类
class stage{
    Room[][] r;
    //构造方法
    public stage(){}
    public stage(Room[][] r){
        this.r=r;
    }
    //前台预定
    public void showPre(int id){
        int height = id / 100;
        int weight = id % 10;
        r[height-1][weight-1].pre();
    }
    //前台退房
    public void showExit(int id){
        int height = id / 100;
        int weight = id % 10;
        r[height-1][weight-1].exit();
    }
    //前台展示房间状态
    public void showMenu(){
        for (int i = 0; i <r.length; i++) {
            for (int j = 0; j <r[i].length; j++) {
                r[i][j].show();
            }
        }
    }
}

//房间类
class Room{
    int id;
    String type;
    String full;
    //构造方法
    public Room(){}
    public Room(int id,String type,String full){
        this.id=id;
        this.type=type;
        this.full=full;
    }
    //房间预定
    public void pre(){
        this.full="有客";
    }
    //房间退房
    public void exit(){
        this.full="空";
    }
    //展示房间状态
    public void show(){
        System.out.println("房间号:"+this.id+",类型为:"+this.type+",此时状态为:"+this.full);
    }

}

小白一枚,欢迎评论、给出建议和指出错误!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值