SoftwareDesignFinal - Quiz Game Overview It is a console-based quiz game developed as a final project for a Software Design Principles class. It uses three classic design patterns—Factory, Strategy, and Proxy—within its design to enhance its flexibility, scalability, and separation of concerns.
Players are presented with a series of questions and awarded points based on their answers. Some of the questions are marked as "premium," and users must have permission to be able to view them.
Design Patterns Used Factory Pattern — Question Creation Purpose: To abstract the creation of various question types without coupling the client code to specific classes.
In This Project:
The Factory Pattern is used to instantiate various kinds of quiz questions (e.g., multiple choice, true/false).
The game outsources question instantiation to a QuestionFactory, which returns the appropriate subclass of a Question base class.
Benefits:
New question types are added easily without modifying existing logic.
Promotes Open/Closed Principle by extracting instantiation logic.
Proxy Pattern — Premium Question Access Purpose: To control access to certain parts of the program—namely premium content.
In This Project:
A QuestionProxy is wrapped around actual questions.
When a question is flagged as premium, the proxy checks whether the player has access.
If not, it prevents the user from seeing the content and displays an appropriate message.
Benefits:
Adds access control without altering the basic question logic.
Separates business logic (quiz flow) from access rules.
Strategy Pattern — Points Calculation Purpose: To encapsulate different algorithms for scoring and make them interchangeable.
In This Project:
The Strategy Pattern is utilized to calculate the player's score based on different criteria (e.g., fixed points per question, weighted scoring).
Different ScoringStrategy implementations can be applied depending on game mode or question type.
Benefits:
Allows flexible score calculation logic.
Enables future additions or modifications (e.g., bonus rounds or difficulty multipliers) without altering underlying game code.
Example Flow User starts the game and is presented with questions generated by the factory.
When a premium question is reached, the proxy determines whether to allow access.
When answering, the strategy pattern is employed to calculate the score based on the selected scoring method.