diff --git a/.idea/misc.xml b/.idea/misc.xml index a165cb3..dc565b0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/flashcards/Main.java b/src/flashcards/Main.java index d1b036c..d043d34 100644 --- a/src/flashcards/Main.java +++ b/src/flashcards/Main.java @@ -1,7 +1,34 @@ package flashcards; +import java.util.Scanner; + public class Main { - public static void main(String[] args) { - System.out.print("Hello world!"); + + public static void main(String[] args) { + try (Scanner scanner = new Scanner(System.in)) { + System.out.printf("Input the number of cards:\n"); + + int numCards = Integer.parseInt(scanner.nextLine()); + + String[] cards = new String[numCards]; + String[] definitions = new String[numCards]; + + for (int i = 0; i < numCards; i++) { + System.out.printf("The card #%d:\n", i + 1); + cards[i] = scanner.nextLine(); + System.out.printf("The definition of the card #%d:\n", i + 1); + definitions[i] = scanner.nextLine(); + } + + for (int i = 0; i < numCards; i++) { + System.out.printf("Print the definition of \"%s\":\n", cards[i]); + String guess = scanner.nextLine(); + if (definitions[i].equals(guess)) { + System.out.printf("Correct answer. "); + } else { + System.out.printf("Wrong answer (the correct one is \"%s\").", definitions[i]); + } + } } + } } \ No newline at end of file