Package SolvishR

Class Exam

java.lang.Object
SolvishR.Exam
Direct Known Subclasses:
NonTimedExam, TimedExam

public abstract class Exam extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a question to the exam.
    int
    Gets the number of correct answers in the exam.
    int
    Gets the number of incorrect answers in the exam.
    double
    Calculates the exam score based on correct and incorrect answers.
    int
    Gets the number of unanswered questions in the exam.
    abstract void
    Abstract method to be implemented by specific exam implementations.
    void
    Sets the list of questions for the exam.
    void
    Displays the results of the exam, including the number of correct, incorrect, and unanswered questions, and the score.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Exam

      public Exam()
  • Method Details

    • addQuestion

      public void addQuestion(Question question)
      Adds a question to the exam.
      Parameters:
      question - The question to add to the exam.
    • setQuestions

      public void setQuestions(List<Question> questions)
      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.