Exam.java
public class Exam {
public static void main(String[] args) {
ExamView EV = new ExamView() ;
EV.testExam();
}
}
ExamView.java
import java.util.Scanner;
public class ExamView {
private ItemService IS = new ItemService() ;
private char[] answer ;
public char getUserAction(){
char[] validKey = {
'1', '2', '3', 'A', 'B', 'C', 'D', 'F', 'N', 'P', 'Y'} ;
char key = 0 ;
Scanner scanner = new Scanner(System.in) ;
while (scanner.hasNext()){
String str = scanner.next() ;
if (str.length() != 1){
continue;
}
str = str.toUpperCase() ;
key = str.charAt(0) ;
for (char k : validKey){
if (k == key){
return key ;
}
}
}
return key ;
}
public void displayItem(int no){
System.out.println(IS.getItem(no+1).getQuestion());
String[] options = IS.getItem(no+1).getOptions