Java實(shí)現(xiàn)簡單的酒店管理系統(tǒng)
本文實(shí)例為大家分享了java實(shí)現(xiàn)酒店管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
要求:
【酒店管理系統(tǒng)】HotelSystem.java
某酒店有12層樓,每層樓有10個(gè)房間(二維數(shù)組),要求為該酒店設(shè)計(jì)一套簡單的前臺(tái)房間管理程序,
該程序可以通過在命令行輸入命令來為客人辦理入住和退房手續(xù)。
要求該程序支持通過命令行輸入以下命令來進(jìn)行入住,退房及查詢的操作:
(1)、search:查詢所有房間的狀態(tài) 無人住顯示empty,有人則顯示住戶姓名
(2)、in 房間號碼 姓名 :客人入住 命令:in 請輸入客人入住的房間號 1202 請輸入入住1202房間的顧客的姓
名 parker 提示:姓名為parker的客人入住1202房間
注意:如果某個(gè)房間已經(jīng)有客人入住,在辦理入住時(shí),將提示“該房間已有客人入住”
(3)、out 房間號碼:客人退房 命令:out 1202 提示:1202房間退房
(4)、quit:退出程序
實(shí)現(xiàn):
import java.util.Scanner;
public class HotelSystem {
//房間數(shù)量
int[][] house=new int[12][10];
//住戶姓名
String[] householdName=new String[120];
public HotelSystem()
{
Init();
}
//初始化數(shù)組
public void Init()
{
for(int i=0;i<12;i++)
{
for(int j=0;j<10;j++)
{
house[i][j]=0;
}
}
}
//查詢
public void Search(HotelSystem hotel)
{
System.out.println("■■■■■■■■■■■■房間狀態(tài)查詢結(jié)果如下■■■■■■■■■■■■");
for(int i=0;i<12;i++)
{
for(int j=0;j<10;j++)
{
if(hotel.house[i][j]==0)
{
System.out.println(i*10+j+1+"號房間無人居住");
}
else if(hotel.house[i][j]==1)
{
System.out.println(i*10+j+1+"號房間"+hotel.householdName[i*10+j+1]+"在住");
}
}
}
}
//入住
public void InHouse(HotelSystem hotel,int housNums,String name,Scanner sc)
{
System.out.println("■■■■■■■■■■■■客人入住■■■■■■■■■■■■");
System.out.println("請輸入客人入住的房間號");
housNums=sc.nextInt();
System.out.println("請輸入入住"+housNums+"房間的顧客的姓名");
name=sc.next();
for(int i=0;i<12;i++)
{
for(int j=0;j<10;j++)
{
if(housNums==(i*10+j+1) && hotel.house[i][j]==0)
{
hotel.house[i][j]=1;
hotel.householdName[housNums]=name;
System.out.println("姓名為"+hotel.householdName[housNums]
+"的客人入住"+housNums+"號房間");
return;
}
else if(housNums==(i*10+j+1) && hotel.house[i][j]==1)
{
System.out.println("不好意思該房間已有客人入住");
return;
}
}
}
}
//退房
public void OutHouse(HotelSystem hotel,int housNums,Scanner sc)
{
System.out.println("■■■■■■■■■■■■客人退房■■■■■■■■■■■■");
System.out.println("請輸入需要退房的房間號");
housNums=sc.nextInt();
for(int i=0;i<12;i++)
{
for(int j=0;j<10;j++)
{
if(housNums==(i*10+j+1) && hotel.house[i][j]==1)
{
hotel.house[i][j]=0;
System.out.println(housNums+"號房間成功退房");
return;
}
}
}
System.out.println("退房失?。?);
}
//退出
public void Quit()
{
System.out.println("■■■■■■■■■■■■退出程序■■■■■■■■■■■■");
System.out.println("■■■■■■■■■■■■感謝使用,系統(tǒng)正在退出...■■■■■■■■■■■■");
}
public static void main(String[] args) {
HotelSystem hotel=new HotelSystem();
String command=null;
int housNums=0;
String name=null;
Scanner sc=new Scanner(System.in);
while(true)
{
System.out.println("■■■■■■■■■■■酒店管理系統(tǒng)命令■■■■■■■■■■■■■");
System.out.println("■■■■■■■■■■■1、search ■■■■■■■■■■■■■");
System.out.println("■■■■■■■■■■■2、in ■■■■■■■■■■■■■");
System.out.println("■■■■■■■■■■■3、out ■■■■■■■■■■■■■");
System.out.println("■■■■■■■■■■■4、quit ■■■■■■■■■■■■■");
System.out.println("請輸入你需要執(zhí)行的命令");
command=sc.next();
if(command.equals("search"))
{
hotel.Search(hotel);
}
else if(command.equals("in"))
{
hotel.InHouse(hotel, housNums, name, sc);
}
else if(command.equals("out"))
{
hotel.OutHouse(hotel, housNums, sc);
}
else if(command.equals("quit"))
{
hotel.Quit();
return;
}
}
}
}關(guān)于管理系統(tǒng)的更多內(nèi)容請點(diǎn)擊《管理系統(tǒng)專題》進(jìn)行學(xué)習(xí)
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Java代碼實(shí)現(xiàn)酒店管理系統(tǒng)
- Java實(shí)現(xiàn)簡單酒店管理系統(tǒng)
- Java實(shí)戰(zhàn)之酒店人事管理系統(tǒng)的實(shí)現(xiàn)
- Java 實(shí)戰(zhàn)練手項(xiàng)目之酒店管理系統(tǒng)的實(shí)現(xiàn)流程
- 基于JavaSwing設(shè)計(jì)和實(shí)現(xiàn)的酒店管理系統(tǒng)
- java實(shí)現(xiàn)酒店管理系統(tǒng)
- Java swing實(shí)現(xiàn)酒店管理系統(tǒng)
- Java實(shí)現(xiàn)酒店客房管理系統(tǒng)
- Java代碼實(shí)現(xiàn)簡單酒店管理系統(tǒng)
相關(guān)文章
SpringCloudGateway 網(wǎng)關(guān)登錄校驗(yàn)實(shí)現(xiàn)思路
文章介紹了在微服務(wù)架構(gòu)中使用Spring Cloud Gateway進(jìn)行登錄校驗(yàn)的方法,通過在網(wǎng)關(guān)層面進(jìn)行登錄校驗(yàn),并將用戶信息通過請求頭傳遞給下游微服務(wù),解決了每個(gè)微服務(wù)都需要獨(dú)立進(jìn)行登錄校驗(yàn)的問題,此外,還討論了如何在微服務(wù)之間傳遞用戶信息2024-11-11
MybatisPlus?QueryWrapper常用方法實(shí)例
MyBatis-Plus(opens new window)是一個(gè)MyBatis(opens new window)的增強(qiáng)工具,在 MyBatis的基礎(chǔ)上只做增強(qiáng)不做改變,為簡化開發(fā)、提高效率而生,下面這篇文章主要給大家介紹了關(guān)于MybatisPlus?QueryWrapper常用方法的相關(guān)資料,需要的朋友可以參考下2022-04-04
解決Eclipse/STS中出現(xiàn)Resource is out of sync with the file system
今天小編就為大家分享一篇關(guān)于解決Eclipse/STS中出現(xiàn)Resource is out of sync with the file system的異常問題,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2018-12-12
Spring Boot項(xiàng)目如何同時(shí)支持HTTP和HTTPS協(xié)議的實(shí)現(xiàn)
這篇文章主要介紹了Spring Boot項(xiàng)目如何同時(shí)支持HTTP和HTTPS協(xié)議的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
IDEA啟動(dòng)tomcat控制臺(tái)中文亂碼問題的解決方法(100%有效)
很多人在idea中啟動(dòng)項(xiàng)目時(shí)會(huì)出現(xiàn)控制臺(tái)的中文亂碼,其實(shí)也無傷大雅,但是本人看著不舒服,下面這篇文章主要給大家介紹了關(guān)于IDEA啟動(dòng)tomcat控制臺(tái)中文亂碼問題的解決方法,需要的朋友可以參考下2022-09-09

