Package SolvishR
Class Exam
java.lang.Object
SolvishR.Exam
- Direct Known Subclasses:
NonTimedExam,TimedExam
The abstract SolvishR.Exam class represents a generic exam consisting of a list of questions.
It provides methods to add questions, set questions, get the number of correct, incorrect, and unanswered questions,
calculate the exam score, run the exam, and display the results.
This class is meant to be extended by specific exam implementations.
- Version:
- 1.0
- Author:
- Adib Sakhawat
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddQuestion(Question question) Adds a question to the exam.intGets the number of correct answers in the exam.intGets the number of incorrect answers in the exam.doublegetScore()Calculates the exam score based on correct and incorrect answers.intGets the number of unanswered questions in the exam.abstract voidrunExam()Abstract method to be implemented by specific exam implementations.voidsetQuestions(List<Question> questions) Sets the list of questions for the exam.voidDisplays the results of the exam, including the number of correct, incorrect, and unanswered questions, and the score.
-
Constructor Details
-
Exam
public Exam()
-
-
Method Details
-
addQuestion
Adds a question to the exam.- Parameters:
question- The question to add to the exam.
-
setQuestions
Sets the list of questions for the exam.- Parameters:
questions- The list of questions to set for the exam.
-
getCorrect
public int getCorrect()Gets the number of correct answers in the exam.- Returns:
- The number of correct answers.
-
getIncorrect
public int getIncorrect()Gets the number of incorrect answers in the exam.- Returns:
- The number of incorrect answers.
-
getUnanswered
public int getUnanswered()Gets the number of unanswered questions in the exam.- Returns:
- The number of unanswered questions.
-
getScore
public double getScore()Calculates the exam score based on correct and incorrect answers.- Returns:
- The exam score.
-
runExam
public abstract void runExam()Abstract method to be implemented by specific exam implementations. It represents the process of running the exam. -
showResults
public void showResults()Displays the results of the exam, including the number of correct, incorrect, and unanswered questions, and the score. Saves the exam using SolvishR.ExamSaver.
-