酒店管理系統(tǒng)是一款功能強(qiáng)大、操作簡(jiǎn)便的酒店管理軟件,是酒店進(jìn)行前臺(tái)管理、電話預(yù)定管理、收銀管理、統(tǒng)計(jì)查詢管理、會(huì)員管理、房卡管理、庫(kù)存管理、報(bào)表管理、經(jīng)理查詢、系統(tǒng)維護(hù)等的必備工具。要實(shí)現(xiàn)這樣的系統(tǒng)需要費(fèi)些功夫,通過(guò)java實(shí)現(xiàn)簡(jiǎn)單的功能。
10年積累的成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有長(zhǎng)汀免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
思路:
共有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ù)代表酒店的基本功能,入住,退房,查詢,其他;
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String temp = null;
while(true){
//提醒用戶選擇輸入
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)輸入查詢的房間號(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]);
}
}
}}
分享題目:java實(shí)現(xiàn)酒店系統(tǒng)
本文路徑:http://chinadenli.net/article46/iecjeg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、App開(kāi)發(fā)、網(wǎng)站導(dǎo)航、響應(yīng)式網(wǎng)站、軟件開(kāi)發(fā)、定制網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)