酒店管理系統(tǒng)是一款功能強(qiáng)大、操作簡(jiǎn)便的酒店管理軟件,是酒店進(jìn)行前臺(tái)管理、電話(huà)預(yù)定管理、收銀管理、統(tǒng)計(jì)查詢(xún)管理、會(huì)員管理、房卡管理、庫(kù)存管理、報(bào)表管理、經(jīng)理查詢(xún)、系統(tǒng)維護(hù)等的必備工具。要實(shí)現(xiàn)這樣的系統(tǒng)需要費(fèi)些功夫,通過(guò)java實(shí)現(xiàn)簡(jiǎn)單的功能。
思路:
共有5層,每層10間客房,以數(shù)字101--509標(biāo)示;
具有入住,退房,搜索,退出四個(gè)簡(jiǎn)單功能;
public class Hotel {
static final int floor = 5;
static final int order = 10;
private static int countFloor;
private static int countOrder;
private static String[][] rooms = new String[floor][order];
//main函數(shù)代表酒店的基本功能,入住,退房,查詢(xún),其他;
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String temp = null;
while(true){
//提醒用戶(hù)選擇輸入
System.out.println("請(qǐng)選擇輸入 in out search quit : ");
temp = scan.next();
int room = 0;
if("in".equals(temp)){
while(true){
System.out.println("請(qǐng)輸入房間號(hào):");
room = scan.nextInt();
if(isRightRoom(room,1)){
break;
}
}
System.out.println("請(qǐng)輸入名字:");
String name = scan.next();
if(in(room,name)){
System.out.println("恭喜您,入住成功");
System.out.println(room + " : "+name);
}
}else if("out".equals(temp)){
while(true){
System.out.println("請(qǐng)輸入房間號(hào):");
room = scan.nextInt();
if(isRightRoom(room,0)){
break;
}
}
if(out(room)){
System.out.println("退房成功,歡迎下次光臨");
}
}else if("search".equals(temp)){
System.out.println("請(qǐng)輸入查詢(xún)的房間號(hào)(-1表示全部)");
room = scan.nextInt();
search(room);
}else if("quit".equals(temp)){
break;
}else{
System.out.println("您的輸入有誤,請(qǐng)?jiān)俅屋斎耄?quot;);
}
}
}
//flag:1 檢查房間號(hào)輸入正確 且 無(wú)人入住 0 僅檢查房間號(hào)輸入正確
private static boolean isRightRoom(int room,int flag) {
//校驗(yàn)房間號(hào)是否輸入有誤
countFloor = room / 100 - 1;
countOrder = room % 100 - 1;
if(countFloor < 0 || countFloor >= floor || countOrder < 0 || countOrder >= order ){
System.out.println("輸入的房間號(hào)有誤");
return false;
}
if(flag == 1){
if(rooms[countFloor][countOrder] != null){
System.out.println("房間已經(jīng)入住");
return false;
}
}
return true;
}
//旅館入住功能實(shí)現(xiàn),in(room,name) countFloor:計(jì)算出的樓層 countOrder:計(jì)算出的房間順序
private static boolean in(int room,String name){
rooms[countFloor][countOrder] = name;
return true;
}
//旅館退房功能實(shí)現(xiàn),out(room),
private static boolean out(int room){
//校驗(yàn)房間號(hào)是否有人入住
if(rooms[countFloor][countOrder] == null){
System.out.println("房間未曾入住,退房有誤");
return false;
}
rooms[countFloor][countOrder] = null;
return true;
}
//旅館搜索功能,search(room)
private static void search(int room){
if(room == -1){
int roomNum = 0;
for(int i=0;i<floor;i++){
for(int j=0;j<order;j++){
roomNum = (i + 1) * 100 + j + 1;
System.out.println(roomNum + "->" +
(rooms[i][j] == null ? "empty" : rooms[i][j]));
}
}
}else{
//校驗(yàn)房間號(hào)是否正確
if(!isRightRoom(room,0)){
System.out.println("抱歉,房間輸入錯(cuò)誤!");
}else{
System.out.println(rooms[countFloor][countOrder]);
}
}
}}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。
名稱(chēng)欄目:java實(shí)現(xiàn)酒店系統(tǒng)-創(chuàng)新互聯(lián)
文章出自:http://jinyejixie.com/article32/cccjpc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、面包屑導(dǎo)航、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、App開(kāi)發(fā)、企業(yè)建站、企業(yè)網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容