【JAVASE系列】11_酒店订房系统
生活随笔
收集整理的這篇文章主要介紹了
【JAVASE系列】11_酒店订房系统
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
文章目錄
- 酒店管理系統(tǒng)
酒店管理系統(tǒng)
-
為某個酒店編寫程序:酒店管理系統(tǒng),模擬訂房,退房,打印所有房間狀態(tài)等功能
- 1、該系統(tǒng)的用戶是酒店的前臺
- 2、酒店當(dāng)中所有的房間使用一個二維數(shù)組來模擬
- 3、酒店當(dāng)中的每一個房間應(yīng)該是一個java對象:Room
- 4、每一個房間Room應(yīng)該有:房間編號,房間類型屬性,房間是否空閑
Hotel.java
HotelSystem.java
/*** Created with IntelliJ IDEA.* Description:* User: Lenovo* Date: 2022-07-03* Time: 18:01*/ public class HotelSystem {public static void main(String[] args) {System.out.println("歡迎使用酒店管理系統(tǒng),請認(rèn)真閱讀以下說明:");System.out.println("請輸入對應(yīng)的功能編號:【1】查看房間列表。【2】訂房。【3】退房。【0】退出系統(tǒng)");Scanner s=new Scanner(System.in);Hotel hotel=new Hotel();while(true){System.out.print("請輸入功能編號:");int i=s.nextInt();if(i==1){//查看房間列表hotel.print();}else if(i==2){//訂房System.out.print("請輸入要訂房的房間號碼:");int numNo=s.nextInt();hotel.order(numNo);}else if(i==3){//退房System.out.print("請輸入要退房的房間號碼:");int numNo=s.nextInt();hotel.exit(numNo);}else if(i==0){//退出系統(tǒng)System.out.print("已退出系統(tǒng)");return;}else {System.out.print("輸入錯誤,請重新輸入:");}}} }Room.java
/*** Created with IntelliJ IDEA.* Description:酒店的房間* User: Lenovo* Date: 2022-07-02* Time: 20:48*/import java.util.Objects; import java.util.Scanner;/*** 酒店的房間*/ public class Room {/*** 房間編號:int no* 1樓:101 102 103...* 2樓:201 202 203...* 3樓:301 302 303...* ...*/private int no;/*** 房間類型:標(biāo)準(zhǔn)間,單人間,總統(tǒng)套房* String type*/private String type;/*** 房間狀態(tài)* true:表示空閑,房間可以被預(yù)定* false:表示占用,房間不能被預(yù)定* boolean status*/private boolean status;//構(gòu)造方法public Room(int no, String type, boolean status) {this.no = no;this.type = type;this.status = status;}public Room() {}//set和get方法public int getNo() {return no;}public void setNo(int no) {this.no = no;}public String getType() {return type;}public void setType(String type) {this.type = type;}public boolean isStatus() {return status;}public void setStatus(boolean status) {this.status = status;}//equals方法重寫@Overridepublic boolean equals(Object o) {if (this == o) return true;if (o == null || getClass() != o.getClass()) return false;Room room = (Room) o;return no == room.no && status == room.status && Objects.equals(type, room.type);}@Overridepublic int hashCode() {return Objects.hash(no, type, status);}//toString方法重寫@Overridepublic String toString() {return "[" + "房間編號:" + no + ", 房間類型:'" + type + ", 房間狀態(tài):" + status + ']';}}總結(jié)
以上是生活随笔為你收集整理的【JAVASE系列】11_酒店订房系统的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [旧文]图解nlite精简XP全过程
- 下一篇: 酒店订房管理系统——注册