博客
关于我
Java小项目源码
阅读量:217 次
发布时间:2019-03-01

本文共 4322 字,大约阅读时间需要 14 分钟。

酒店管理系统开发方案

项目概述

本项目旨在开发一个模拟酒店管理系统,提供完整的预定、退房及房间状态查看功能。系统将使用二维数组模拟酒店房间布局,每个房间将作为一个Java对象处理。

系统模拟

  • 用户:酒店前台工作人员
  • 数据结构:使用二维数组Room[][] rooms模拟酒店房间布局
  • 房间类:每个房间Room对象包含以下属性:
    • 房间编号
    • 房间类型(如标准间、单人间、总统套房)
    • 房间状态(true表示空闲,false表示已占用)

系统功能

  • 预定房间:用户输入房间编号,系统将对应房间状态改为false(空闲)
  • 退房:用户输入房间编号,系统将对应房间状态改为true(已占用)
  • 查看房间状态:用户可通过输入特定指令查看所有房间状态
  • 功能实现

    package Test;public class Room {    private int ID;    private String type;    private boolean status;    public Room(int ID, String type, boolean status) {        this.ID = ID;        this.type = type;        this.status = status;    }    public int getID() {        return ID;    }    public void setID(int ID) {        this.ID = ID;    }    public String getType() {        return type;    }    public void setType(String type) {        this.type = type;    }    public boolean getStatus() {        return status;    }    public void setStatus(boolean status) {        this.status = status;    }    @Override    public String toString() {        return "Room [ID=" + ID + ", Type='" + type + "', Status=" + (status ? "空闲" : "已占用") + "]";    }    @Override    public boolean equals(Object o) {        if (this == o) return true;        if (o == null || getClass() != o.getClass()) return false;        Room room = (Room) o;        return ID == room.ID;    }    @Override    public int hashCode() {        return Objects.hash(ID, type, status);    }}public class Hotel {    private Room[][] rooms;    private int floorNum;    private int roomNum;    public Hotel(Room[][] rooms) {        this.rooms = rooms;    }    public Hotel(int floorNum, int roomNum) {        this(new Room[floorNum][roomNum]);        initializeRooms(floorNum, roomNum);    }    private void initializeRooms(int floorNum, int roomNum) {        for (int i = 0; i < floorNum; i++) {            for (int j = 0; j < roomNum; j++) {                switch (i) {                    case 0:                        int id1 = Integer.parseInt("10" + (j + 1));                        rooms[i][j] = new Room(id1, "单人间", true);                        break;                    case 1:                        int id2 = Integer.parseInt("20" + (j + 1));                        rooms[i][j] = new Room(id2, "标准间", true);                        break;                    case 2:                        int id3 = Integer.parseInt("30" + (j + 1));                        rooms[i][j] = new Room(id3, "总统套房", true);                        break;                }            }        }    }    public void showRoomMessage() {        for (int i = 0; i < rooms.length; i++) {            for (int j = 0; j < rooms[i].length; j++) {                Room room = rooms[i][j];                System.out.println(room);                System.out.println("-------------------");            }        }    }    public void order(int roomID) {        int row = roomID / 100;        int column = roomID % 100;        if (row < 0 || row >= rooms.length || column < 0 || column >= rooms[row].length) {            System.out.println("输入的房间编号无效,请重新输入:");            return;        }        Room room = rooms[row][column];        if (room.getStatus()) {            room.setStatus(false);            System.out.println("预定成功!" + roomID + "已被标记为空闲");        } else {            System.out.println("该房间已被占用,无法预定,请选择其他房间!");        }    }    public void checkOut(int roomID) {        int row = roomID / 100;        int column = roomID % 100;        if (row < 0 || row >= rooms.length || column < 0 || column >= rooms[row].length) {            System.out.println("输入的房间编号无效,请重新输入:");            return;        }        Room room = rooms[row][column];        if (!room.getStatus()) {            System.out.println("该房间已是空闲,无需退房!");            return;        }        room.setStatus(true);        System.out.println("退房成功!" + roomID + "已被标记为已占用");    }    public int getFloorNum() {        return floorNum;    }    public void setFloorNum(int floorNum) {        this.floorNum = floorNum;    }    public int getRoomNum() {        return roomNum;    }    public void setRoomNum(int roomNum) {        this.roomNum = roomNum;    }}

    功能说明

    • Room类:用于表示酒店房间,包含房间编号、类型及状态信息
    • Hotel类:管理酒店房间信息,提供订房、退房及房间状态查看功能
    • 初始化方法:根据楼层和房间数量初始化房间布局
    • 显示房间信息:遍历所有房间并打印当前状态
    • 订房功能:根据输入房间编号修改房间状态
    • 退房功能:根据输入房间编号恢复房间状态

    使用说明

  • 创建酒店实例时需指定楼层数和房间数量
  • 初始化方法会根据楼层和房间数量创建相应房间
  • showRoomMessage方法可查看所有房间状态
  • order方法用于订房,checkOut方法用于退房
  • 转载地址:http://pljv.baihongyu.com/

    你可能感兴趣的文章
    Nginx在Windows下载安装启动与配置前后端请求代理
    查看>>
    Nginx多域名,多证书,多服务配置,实用版
    查看>>
    nginx开机启动脚本
    查看>>
    nginx异常:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf
    查看>>
    nginx总结及使用Docker创建nginx教程
    查看>>
    nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:128
    查看>>
    nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in usrlocalnginxconfnginx.conf128
    查看>>
    nginx日志分割并定期删除
    查看>>
    Nginx日志分析系统---ElasticStack(ELK)工作笔记001
    查看>>
    Nginx映射本地json文件,配置解决浏览器跨域问题,提供前端get请求模拟数据
    查看>>
    nginx最最最详细教程来了
    查看>>
    Nginx服务器---正向代理
    查看>>
    Nginx服务器上安装SSL证书
    查看>>
    Nginx服务器的安装
    查看>>
    Nginx模块 ngx_http_limit_conn_module 限制连接数
    查看>>
    nginx添加模块与https支持
    查看>>
    Nginx用户认证
    查看>>
    Nginx的location匹配规则的关键问题详解
    查看>>
    Nginx的Rewrite正则表达式,匹配非某单词
    查看>>
    Nginx的使用总结(一)
    查看>>