diff --git a/src/QuizController.java b/src/QuizController.java deleted file mode 100644 index 1670406..0000000 --- a/src/QuizController.java +++ /dev/null @@ -1,97 +0,0 @@ -import java.util.*; - -public class QuizController { - private QuestionGenerator questionGenerator; - private List currentQuiz; - private int currentQuestionIndex; - private int score; - private Map userAnswers; - - public static class Question { - private int id; - private String content; - private String[] options; - private int correctAnswer; - private String difficulty; - - public Question(int id, String content, String[] options, int correctAnswer, String difficulty) { - this.id = id; - this.content = content; - this.options = options; - this.correctAnswer = correctAnswer; - this.difficulty = difficulty; - } - - public int getId() { return id; } - public String getContent() { return content; } - public String[] getOptions() { return options; } - public int getCorrectAnswer() { return correctAnswer; } - public String getDifficulty() { return difficulty; } - - public boolean checkAnswer(int userAnswer) { - return userAnswer == correctAnswer; - } - } - - public QuizController() { - this.questionGenerator = new QuestionGenerator(); - this.userAnswers = new HashMap<>(); - } - - public void startNewQuiz(String difficulty, int questionCount) { - this.currentQuiz = questionGenerator.generateQuestionSet(questionCount, difficulty); - this.currentQuestionIndex = 0; - this.score = 0; - this.userAnswers.clear(); - } - - public Question getCurrentQuestion() { - if (currentQuiz == null || currentQuestionIndex >= currentQuiz.size()) { - return null; - } - return currentQuiz.get(currentQuestionIndex); - } - - public boolean submitAnswer(int answer) { - if (currentQuiz == null || currentQuestionIndex >= currentQuiz.size()) { - return false; - } - - Question current = currentQuiz.get(currentQuestionIndex); - userAnswers.put(currentQuestionIndex, answer); - - if (current.checkAnswer(answer)) { - score++; - } - - return true; - } - - public boolean nextQuestion() { - if (currentQuiz == null || currentQuestionIndex >= currentQuiz.size() - 1) { - return false; - } - currentQuestionIndex++; - return true; - } - - public boolean hasNextQuestion() { - return currentQuiz != null && currentQuestionIndex < currentQuiz.size() - 1; - } - - public int getCurrentQuestionNumber() { - return currentQuestionIndex + 1; - } - - public int getTotalQuestions() { - return currentQuiz != null ? currentQuiz.size() : 0; - } - - public int getScore() { - return score; - } - - public double getPercentage() { - return currentQuiz != null ? (double) score / currentQuiz.size() * 100 : 0; - } -} \ No newline at end of file