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

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

**项目名称:**酒店管理系统

**项目需求:**模拟订房、退房、打印所有房间状态等功能
1、该系统的用户:酒店前台
2、酒店使用一个二维数组来模拟,“Room[][] rooms”
3、酒店中的每一个房间应该是一个java对象
4、每一个房间Room应该有:房间编号、房间类型、房间是否空闲
5、系统应该对外提供的功能:
可以预定房间:用户输入房间编号订房
可以退房:用户输入房间编号退房
可以查看所有房间的状态:用户输入某个指令应该可以查看所有房间状态

package Test;import java.util.Objects;/** * 酒店的房间 */public class Room {       /**     * 房间编号     * 1楼:101 102 103 ...     * 2楼:201 202 203 ...     * ...     */    private int ID;    /**     * 房间类型:标准间、单人间、总统套房     */    private String type;    /**     * 房间状态:     * true表示空闲,房间可以被预定     * false表示占用,房间不能被预定     */    private boolean status;    public Room() {       }    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;    }   /*     对于boolean类型的变量,IDEA生成的get方法的方法名是:isXxx()     如果不喜欢,可以修改为:getXxx()    */    /*    public boolean isStatus() {        return status;    }    */    public boolean getStatus() {           return status;    }    public void setStatus(boolean status) {           this.status = status;    }    @Override    public String toString() {           return  "[Room ID:" + ID +'\t'+                "Room type:'" + type + '\t' +                "Room 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);    }}package Test;public class Hotel {       private Room[][] rooms;    private int floor_num;    private int room_num;    public Hotel(Room[][] rooms) {           this.rooms = rooms;    }    public Hotel(int floor_num, int room_num) {           this(new Room[floor_num][room_num]);        for (int i = 0; i 
310||room_num<=100||room_num==200||room_num==300){ System.out.println("您输入的房间编号不正确,请重新输入:"); continue; }else { hotel.order(room_num); break; } } }else if (num==3){ System.out.println("请输入您要退的房间编号:"); while(true){ int room_num = sc.nextInt(); if(room_num>310||room_num<=100||room_num==200||room_num==300){ System.out.println("您输入的房间编号不正确,请输入正确的房间编号:"); continue; }else { hotel.check_Out(room_num); break; } } }else{ System.out.println("您输入的功能编号不正确,请重新输入!"); } } }}

转载地址:http://pljv.baihongyu.com/

你可能感兴趣的文章
mysql 8 远程方位_mysql 8 远程连接注意事项
查看>>
MUI框架里的ajax的三种方法
查看>>
MySQL 8.0 恢复孤立文件每表ibd文件
查看>>
Mysql 8.0 新特性
查看>>
MultCloud – 支持数据互传的网盘管理
查看>>
MySQL 8.0.23中复制架构从节点自动故障转移
查看>>
MySQL 8.0开始Group by不再排序
查看>>
mysql ansi nulls_SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON 什么意思
查看>>
multi swiper bug solution
查看>>
MySQL Binlog 日志监听与 Spring 集成实战
查看>>
MySQL binlog三种模式
查看>>
multi-angle cosine and sines
查看>>
Mysql Can't connect to MySQL server
查看>>
mysql case when 乱码_Mysql CASE WHEN 用法
查看>>
Multicast1
查看>>
mysql client library_MySQL数据库之zabbix3.x安装出现“configure: error: Not found mysqlclient library”的解决办法...
查看>>
MySQL Cluster 7.0.36 发布
查看>>
Multimodal Unsupervised Image-to-Image Translation多通道无监督图像翻译
查看>>
MySQL Cluster与MGR集群实战
查看>>
multipart/form-data与application/octet-stream的区别、application/x-www-form-urlencoded
查看>>