import random
from typing import Dict, List

quiz_set = [
    {"question": "What sound does a dog makes?", "answer": "Woof"},
    {"question": "What sound does a cat makes?", "answer": "Meow"},
    {"question": "What is 2 + 2?", "answer": "4"},
    {"question": "What is sport is Chihayafuru about?", "answer": "karuta"},
]


class Question:
    def __init__(self, question: str, answer: str) -> None:
        self.question = question
        self.answer = answer

    def check_answer(self, input_answer: str) -> bool:
        return input_answer.lower() == self.answer.lower()


class Quiz:
    def __init__(self, question_set: List[Dict[str, str]]) -> None:
        self.questions = self._create_questions(question_set)

    def _create_questions(self, question_set: List[Dict[str, str]]) -> List[Question]:
        """Return a list of Question objects."""
        questions = []
        for question in question_set:
            questions.append(Question(question["question"], question["answer"]))
        random.shuffle(questions)
        return questions


def main(debug=False) -> None:
    """Main game loop."""
    quiz = Quiz(quiz_set)
    print(quiz.questions)
    for question in quiz.questions:
        while True:
            print(question.question)
            answer = str(input("What is your answer?"))
            if question.check_answer(answer):
                print("Correct!")
                break
            print("Wrong answer. Please try again.")
            if debug:
                break


if __name__ == "__main__":
    main()
