I'm coding a test in Java. This is just for fun, got bored, started coding, hit a rut, fixed said rut, now we are here.
Anyway I am just wondering what you guys think of my basic B-Level code.
MAIN CLASS
QUESTION AND ANSWER QAA CLASS
Anyway I am just wondering what you guys think of my basic B-Level code.

MAIN CLASS
Code:
import java.util.ArrayList;
import java.util.Scanner;
public class Quiz {
public static void main(String[] args) {
//Commence scanner
Scanner scan = new Scanner(System.in);
//Starting the quiz.
System.out.println("Hello, I'm Quizita, your personal quiz bot.\nWhat's your name?");
String name = scan.nextLine(); //Name for later use
System.out.println("Oh, hello "+name+". Ready to start the quiz?");
String start = scan.nextLine();
//Staring quiz with text for user
if (start.equalsIgnoreCase("YES")) {
System.out.println("Good let's commence.");
} else {
System.out.println("Okay, I'll take "+start+" as a yes.");
}
//Creating list to hold questions for test
ArrayList<QAA> qaaL = new ArrayList<QAA>();
//Adding questions | Use format below
//qaaL.add(new QAA("Question blank text?"
// + "\nA) ExA\nB) ExB\nC) ExC", "<letter>"));
qaaL.add(new QAA("What is the name of the Greek God of the Sea?"
+ "\nA) Zeus\nB) Poseidon\nC) Hades", "b"));
qaaL.add(new QAA("What is the name of the father of the first Olympians?"
+ "\nA) Chronos\nB) Prometheus\nC) Titanus", "a"));
ArrayList<String> ans = new ArrayList<String>();
//Asking question, getting answer and logging
for(int i = 0; i < qaaL.size(); i++) {
System.out.println(qaaL.get(i).getQuestion());
ans.add(scan.nextLine());
}
//Calculating Score with Comparison
int score = 0;
for(int i = 0; i < qaaL.size(); i++) {
if(qaaL.get(i).getAnswer().equalsIgnoreCase(ans.get(i)))
score++;
}
//Ending result
System.out.println("Your got "+score+" question(s) correct out of "+qaaL.size()+".");
}
}
QUESTION AND ANSWER QAA CLASS
Code:
public class QAA {
private String question;
private String answer;
public QAA(String question, String answer) {
this.question=question;
this.answer=answer;
}
public String getQuestion() {
return this.question;
}
public String getAnswer() {
return this.answer;
}
}
Last edited: