其他分享
首页 > 其他分享> > -欢迎光临酒店管理系统

-欢迎光临酒店管理系统

作者:互联网



            


package com.dom;
import java.util.List;
import java.util.Map;
public interface Hotels {                            接口
    public List<Map<String, Object>> select() throws Exception;
    public int update(Object[] params) throws Exception;
    public int delete(Object[] params) throws Exception;
}


 



package com.dom.hotelsachieve;
import com.dom.Hotels;
import com.factory.DbManager;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Hotelsachieve implements Hotels {
    private String p_name;
    @Override
    public List<Map<String, Object>> select() throws Exception {
        String sql="select * from h_room";
        List<Map<String,Object>> listqery= DbManager.query(sql,null);
        for (int i = 0; i < listqery.size(); i++) {
            Map<String,Object> map=listqery.get(i);
            Set<String> set= map.keySet();
            for(String s : set){
                System.out.print(s+":"+map.get(s));
            }
            System.out.println();
        }
    return listqery;                                    接口实现类
    }
    @Override
    public int update(Object[] params) throws Exception {
        String update="update  h_room set h_type=? where h_card=?";
        int i=DbManager.update(update,params);
        return i;
    }
    @Override
    public int delete(Object[] params) throws Exception {
        String delete="delete from h_room where h_card=?";
        int i=DbManager.update(delete,params);
        return i;
    }
}










package com.test;
import com.dom.Hotels;
import com.dom.hotelsachieve.Hotelsachieve;                        调用及更换    
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class Hotel_test {

    Hotels hotels=new Hotelsachieve();
    public void select() throws Exception {
        List<Map<String,Object>> list =hotels.select();
    }
    public void update() throws Exception {        
        Object[] objects=new Object[2];               ---》    //update  h_room set h_type=? where h_card=?
        objects[0]="she" ;                下标0为第一个?  更改成的            
        objects[1]="get";                下标1为第二个?  条件
        int i=hotels.update(objects);
        System.out.println("成功执行"+i+"条命令");
    }
    public void delete() throws Exception {
        Object[] objects=new Object[1];
        objects[0]="004";
        int i=hotels.delete(objects);
        System.out.println("成功执行"+i+"条命令");
    }
}







package com.test;
import java.util.Scanner;
public class Test {
    public static void main(String[] args) throws Exception {                    调用出
        Scanner scanner=new Scanner(System.in);
        Hotel_test hotel_test=new Hotel_test();
        System.out.println("-----欢迎光临酒店管理系统----");
        System.out.println("请选择: 1,查看所有顾客 2:更换房间 3:退房 4更据房间类型查询房间信息");
        int choose=scanner.nextInt();
        switch (choose){
            case 1:
                hotel_test.select();
          break;
            case 2:
                 hotel_test.update();
                 hotel_test.select();
                break;
            case 3:
                hotel_test.delete();
                break;
            case 4:
                hotel_test.update();
                break;
        }
    }
}






package com.test;
import java.util.Scanner;
public class Test {
    public static void test() throws Exception {
        Scanner scanner=new Scanner(System.in);
        Hotel_test hotel_test=new Hotel_test();
        System.out.println("-----欢迎光临酒店管理系统----");
        System.out.println("请选择: 1,查看所有顾客 2:更换房间 3:退房 4更据房间类型查询房间信息");
        int choose=scanner.nextInt();
        switch (choose){
            case 1:
                hotel_test.select();
                break;
            case 2:
                hotel_test.update();
                hotel_test.select();
                break;
            case 3:
                hotel_test.delete();
                break;
            case 4:
                hotel_test.select2();
                break;
        }
    }
    public static void main(String[] args) throws Exception {
        Scanner scanner=new Scanner(System.in);
        boolean flag=false;
        do{
            test();
            System.out.println("继续/退出  y/n");
            String choose2=scanner.next();
            if(choose2.equals("y")) {
                test();
                flag=true;
            }else {
                System.out.println("正在退出程序!");
                flag=false;
            }
        }while (flag);
    }
}

标签:欢迎光临,管理系统,throws,System,update,酒店,test,import,public
来源: https://www.cnblogs.com/gzh-like-your/p/14472314.html