科目三模拟灯光考试Java代码

鉴于本人最近才考科目三,顺带手写了个小玩意,可以模拟一下科三中的灯光模拟考试。15道题随机抽5道,基本上还原了真实考试情景,有需要的可尝试一下

public class DriverLightTest {
     static Map<String, String> qaMap = new HashMap<>();
     static List<String> list = new ArrayList();

    static {
        qaMap.put("夜间通过急弯","远近");
        qaMap.put("夜间通过坡道","远近");
        qaMap.put("夜间通过拱桥","远近");
        qaMap.put("夜间通过人行横道","远近");
        qaMap.put("夜间超越前方车辆","远近");
        qaMap.put("夜间通过没有交通信号灯的路口","远近");
        qaMap.put("夜间通过有交通信号灯的路口","近");
        qaMap.put("夜间同方向近距离跟车","近");
        qaMap.put("夜间与机动车会车","近");
        qaMap.put("夜间在照明良好的道路行驶","近");
        qaMap.put("夜间直行通过路口","近");
        qaMap.put("夜间直行通过照明不良的路口","远");
        qaMap.put("夜间在没有路灯的照明不良条件下行驶","远");
        qaMap.put("路边临时停车","示廓灯+危险信号灯");
        qaMap.put("夜间在道路上发生交通事故,妨碍交通又难以移动","示廓灯+危险信号灯");

        Iterator<Map.Entry<String, String>> iterator = qaMap.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<String, String> next = iterator.next();
            list.add(next.getKey());
        }
    }
    public static void main(String[] args) throws IOException {
        List<Integer> index = getIndex(5, 15);
        for (Integer integer : index) {
            String qs = list.get(integer);
            System.out.println(qs);
            System.out.println("1.近光灯       2.远光灯       3.远近交替      4.示廓灯+危险信号灯");
            Scanner in=new Scanner(System.in);
            Integer as = Integer.valueOf(in.next());
            String s = qaMap.get(qs);
            if((as == 1 && s.equals("近"))
                || (as == 2 && s.equals("远"))
                || (as == 3 && s.equals("远近"))
                || (as == 4 && s.equals("示廓灯+危险信号灯"))){
                System.out.println("ok!");
                System.out.println();
            }else {
                System.out.println("false! quit");
                System.out.println("answer is " + s);

                break;
            }
        }
    }

    static List<Integer> getIndex(int i, int max){
        List<Integer> tempList =  new ArrayList<>();
        Random random = new Random();
        boolean flag = true;
        while (tempList.size() < i){
            int index = random.nextInt(max);
            for (int num : tempList) {
                if(num == index){
                    flag = false;
                    break;
                }
            }
            if(flag){
                tempList.add(index);
            }
            flag = true;
        }

        return tempList;
    }
}
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值