import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;
public class MainApp {
static Map<Integer,String> questionsMap;
static Map<Integer,String> answeredMap;
static Random random;
static Scanner userAnswer;
public static void main(String[] args) {
//1. load the questions
loadQuestions();
//2. initialize the answeredMap container (walang laman muna, standby lang)
initializeAnsweredMap();
//3. initialize random int maker
initializeRandomNumberMaker();
//4. initialize scanner for user input
initializeScanerForUserInput();
//5. itong unang or outer WHILE na ito, siguraduhin lang na hindi pa ubos ang mga QUESTIONS
//tapos pag ubos na ang questions, e-exit na yung APP
while(questionsMap.size() != answeredMap.size()) {
//5A. habang may questions pa, ito ang gagawin niya (this is the INNER WHILE)
int key = 0;
//dahil gusto natin huwag umulit yung questions, dapat mag generate na key
//na wala pa sa answeredMap
while(answeredMap.containsKey(key) || key==0) {
key = random.nextInt(questionsMap.size()) + 1;
}
//5B.pag wala pa yung key sa answeredMap, gagamitin na natin yung key
//na pagkuha ng questions, ganito, tapos display kaagad yung question:
System.out.print(questionsMap.get(key));
//5C.hintayin yung answer ng user
String answer = userAnswer.next();
//5D. tapos pag may sagot na, ilalagay natin yung KEY at SAGOT sa answeredMAP
answeredMap.put(key, answer);
}//end ng unang WHILE or outer WHILE
//6. message lang ito pag ubos na yung mga questions
System.out.println("\n**********************\nWala na. Ubos na mga questions.");
//7. Dito puwede mo na lagyan ng features kagaya ng kung ilan ang mali at ilan ang tama
//o at saka i-display mo yung mga sagot, etc etc etc.
}
static void loadQuestions() {
//initialize bago gamitin
questionsMap = new HashMap<>();
//simulan ng lagyan ng mga questions (as many as you want)
questionsMap.put(1, "What is the shape of the moon?");
questionsMap.put(2, "How many stars in the sky?");
questionsMap.put(3, "What is the square root of 33,333?");
questionsMap.put(4, "What is Bruce Lee good at?");
questionsMap.put(5, "Who is the President of Haiti?");
questionsMap.put(6, "Who inveted the microscope?");
questionsMap.put(7, "Name the colors of Russian flag?");
questionsMap.put(8, "Seven times seven divided 3 plus 1 is?");
questionsMap.put(9, "What is the 50th element in the periodic table?");
questionsMap.put(10, "Who came first, chicken or egg?");
}
static void initializeAnsweredMap() {
answeredMap = new HashMap<>();
}
static void initializeRandomNumberMaker() {
random = new Random();
}
static void initializeScanerForUserInput() {
userAnswer = new Scanner(System.in);
}
}