博客
关于我
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/

    你可能感兴趣的文章
    No module named cv2
    查看>>
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
    查看>>
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    no session found for current thread
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>
    NO.23 ZenTaoPHP目录结构
    查看>>
    no1
    查看>>
    NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
    查看>>
    NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    查看>>
    Node JS: < 一> 初识Node JS
    查看>>
    Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime(72)
    查看>>
    Node-RED中使用JSON数据建立web网站
    查看>>
    Node-RED中使用json节点解析JSON数据
    查看>>
    Node-RED中使用node-random节点来实现随机数在折线图中显示
    查看>>
    Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
    查看>>
    Node-RED中使用node-red-contrib-image-output节点实现图片预览
    查看>>
    Node-RED中使用node-red-node-ui-iframe节点实现内嵌iframe访问其他网站的效果
    查看>>