This repository contains two projects:
- A Multiple-Choice Quiz Game built in Java using the Swing framework.
- A Snake Game, originally developed in Java, with a new version that can be played directly in the browser using JavaScript.
Both projects aim to provide fun and educational experiences for users while showcasing Java programming concepts.
For detailed documentation and project motivation, visit the Wiki Home.
Overview:
This is a simple multiple-choice quiz game built in Java using the Swing framework. The game randomly selects a Java-related question and presents it to the user along with four possible answers.
- Features: Random question selection, immediate feedback, easy to extend with new questions.
- Technologies Used: Java, Swing (for GUI).
Installation:
- Prerequisites: Java 8+ and a Java IDE or command-line tools.
- Clone the repository and compile the code:
git clone https://github.com/your-username/java-multiple-choice-quiz.git javac com/github/karabosithole/Main.java java com.github.karabosithole.Main
This is a simple multiple-choice quiz game built in Java using the Swing framework. The game randomly selects a question from a pool of Java-related questions and presents it to the user along with four possible answers. The user must choose the correct answer from the options presented. Immediate feedback is given on whether the answer is correct or incorrect.
For detailed documentation and project motivation, visit the Wiki Home.
- Multiple-choice questions related to Java programming.
- Random question selection from a pool of predefined questions.
- Interactive GUI using Java Swing for question display and user input.
- Immediate feedback after each answer.
- Easy to extend with additional questions and answers.
- Java 8 or higher
- A Java IDE (e.g., IntelliJ IDEA, Eclipse) or simply
javacfor command-line compilation
-
Clone this repository or download the source code:
git clone https://github.com/your-username/java-multiple-choice-quiz.git
-
Open the project in your preferred Java IDE or navigate to the folder in the terminal.
-
Compile and run the
Mainclass to start the quiz game.Using the terminal:
javac com/github/karabosithole/Main.java java com.github.karabosithole.Main
- When the game starts, a question will be displayed with four answer choices (A, B, C, D).
- Select one of the answers from the dialog box.
- You will receive immediate feedback on whether your answer was correct or incorrect.
- The game will then ask the next question after a short delay.
-
Question: What does JVM stand for?
- A) Java Virtual Machine
- B) Java Visual Model
- C) Java Version Manager
- D) Java Variable Model
Answer: If the user selects "A) Java Virtual Machine," they receive a message indicating whether they were correct.
To add more questions to the game, follow these steps:
- Open the
QuestionManagerclass. - In the
initQuestions()method, add a newQuestionobject with your custom question, answer choices, and the index of the correct answer.
Questions.add(new Question("Your custom question?",
new String[] {"A) Option1", "B) Option2", "C) Option3", "D) Option4"},
2)); // Correct answer is the 3rd option (index 2)- Java: Programming language used to develop the game.
- Swing: Java's GUI framework to display dialogs and capture user input.
Created by Karabo Sithole.