java实现酒店系统-创新互联

酒店管理系统是一款功能强大、操作简便的酒店管理软件,是酒店进行前台管理、电话预定管理、收银管理、统计查询管理、会员管理、房卡管理、库存管理、报表管理、经理查询、系统维护等的必备工具。要实现这样的系统需要费些功夫,通过java实现简单的功能。

创新互联公司专注于企业营销型网站、网站重做改版、歙县网站定制设计、自适应品牌网站建设、HTML5商城开发、集团公司官网建设、外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为歙县等各大城市提供网站开发制作服务。

思路:

共有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实现酒店系统-创新互联
文章出自:https://www.cdcxhl.com/article32/cccjpc.html

成都网站建设公司_创新互联,为您提供网站设计面包屑导航营销型网站建设App开发企业建站企业网站制作

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

h5响应式网站建设