QUIZ
QUIZ
Setting Up:
String arrays store questions, answers, and user answers.
GUI elements like labels, buttons, and radio buttons are defined.
Static variables track time, answers provided, question count, and score.
Constructor (Quiz) takes the user's name, initializes the window, sets background
image, and displays labels.
It also loads sample questions and answers into arrays.
2. Action Performed:
actionPerformed method responds to button clicks.
Next Button:
Enables radio buttons for answering.
Stores the selected answer (if any) in useranswers.
Disables "Next" and enables "Submit" after the last question.
Increments question count and starts displaying the next question.
Lifeline Button:
Disables two incorrect answer options based on the current question.
Disables itself after usage.
Submit Button:
Stores the selected answer (if any) in useranswers.
Calculates the final score based on correct answers.
Hides the current window and shows the Score class with user's name and score.
4. Starting a Question:
start method displays the current question number, text, and answer options with
radio buttons.
5. Main Method:
Starts the application by creating a new Quiz object with the default name "User".
Overall, this code demonstrates a basic Java Swing GUI application for a quiz with
features like multiple-choice questions, time pressure, lifelines, and score
calculation.
Note: This explanation assumes some understanding of Java and GUI programming.
Specific libraries and methods might require further research for deeper
understanding.