鉴于本人最近才考科目三,顺带手写了个小玩意,可以模拟一下科三中的灯光模拟考试。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;
}
}