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