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

    你可能感兴趣的文章
    PermissionError:Python 中的 [Errno 13]
    查看>>
    PermissionError:[Errno 13] 权限被拒绝:‘/manage.py‘
    查看>>
    Permutation
    查看>>
    perspective意思_2020年12月英语四级词汇讲解丨考点归纳:perspective
    查看>>
    PE文件,节头有感IMAGE_SECTION_HEADER
    查看>>
    PE查找文件偏移地址
    查看>>
    PE知识复习之PE的导入表
    查看>>
    PFX(Parallel Framework) and Traditional Multithreading
    查看>>
    PGOS:今天动手给电脑装青苹果Win7 X64位系统
    查看>>
    pgpool-II3.1 的内存泄漏(一)
    查看>>
    PgSQL · 特性分析 · PG主备流复制机制
    查看>>
    PGSQL主键序列
    查看>>
    PGSQL安装PostGIS扩展模块
    查看>>
    Phalcon环境搭建与项目开发
    查看>>
    Phantom.js维护者退出,项目的未来成疑
    查看>>
    Pharmaceutical的同学们都看过来,关于补码运算的复习相关内容
    查看>>
    Phoenix基础命令_视图映射和表映射_数字存储问题---大数据之Hbase工作笔记0036
    查看>>
    phoenix无法连接hbase shell创建表失败_报错_PleaseHoldException: Master is initializing---记录020_大数据工作笔记0180
    查看>>
    Phoenix简介_安装部署_以及连接使用---大数据之Hbase工作笔记0035
    查看>>
    phoenix连接hbase报错Can not resolve hadoop120, please check your network_记录026---大数据工作笔记0187
    查看>>