-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
58 lines (44 loc) · 1.69 KB
/
Main.java
File metadata and controls
58 lines (44 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.scipiogothicus.LanguageTrainer;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
DataParser parser = new DataParser("hiragana.txt");
boolean running = true;
Random rand = new Random();
ArrayList<LanguageNode> languageList = parser.convertDataToNodes();
Scanner scan = new Scanner(System.in); // Create a Scanner object
int seed;
int correct = 0;
int total = 0;
while(running) {
seed = rand.nextInt(0, languageList.size());
LanguageNode currentNode = languageList.get(seed);
System.out.println("What is this word?: " + currentNode.getWord());
String inputPronun = scan.nextLine();
if(inputPronun.equals(currentNode.getPronunciation())) {
System.out.println("Correct!");
correct++;
if(currentNode.hasDefinition()) {
System.out.println("What is the definition of the word " + currentNode.getWord() + "?");
String inputDef = scan.nextLine();
if(inputDef.equals(currentNode.getDefinition())) {
System.out.println("Correct!");
correct++;
}
else {
System.out.println("Incorrect.\nThe correct definition is " + currentNode.getDefinition());
}
total++;
}
}
else {
System.out.println("Incorrect.\nThe correct Japanese word is " + currentNode.getPronunciation());
}
total++;
System.out.println("Current grade: " + (correct*100)/total + "%, " + correct + "/" + total);
}
scan.close();
}
}