Пример #1
0
  public static void displayFlashcard() {
    int size = flashcardSet.size();

    if (currentIndex < size) {
      Main.frame.setContentPane(
          new TermDisplay(flashcardSet.getFlashcard(currentIndex)).getPanel1());
      Main.frame.pack();
      Main.frame.invalidate();

      currentIndex++;
    } else {
      displayCompleted();
    }
  }
Пример #2
0
  private static String getStats() {

    int total = flashcardSet.size();
    int correct = 0;

    for (int index = 0; index < flashcardSet.size(); index++) {
      if (flashcardSet.getFlashcard(index).isCorrect()) {
        correct++;
      }
    }

    return correct
        + "/"
        + total
        + " ("
        + (double) Math.round((double) correct / (double) total * 10000) / 100
        + "%)";
  }
Пример #3
0
  public static void loadFlashcards() {
    try {
      CSVReader reader =
          new CSVReader(new InputStreamReader(new FileInputStream(csvPath), "UTF-16"));

      String[] line;

      while ((line = reader.readNext()) != null) {
        flashcardSet.addFlashcard(new Flashcard(line[0], line[1]));
      }
    } catch (FileNotFoundException e) {
      JOptionPane.showMessageDialog(
          Main.frame, "No file found at " + csvPath, "File Not Found", JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          Main.frame,
          "Unable to load from " + csvPath,
          "Unable to Read From File",
          JOptionPane.ERROR_MESSAGE);
    }
  }