Package SolvishR
Class AdditionQuestion
java.lang.Object
SolvishR.Question
SolvishR.AdditionQuestion
Represents a question related to addition.
Extends the
Question class and provides functionality to generate addition questions with random numbers.- Version:
- 1.0
- Author:
- Adib Sakhawat
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a random addition question with numbers generated between 10 and 10000 (inclusive).AdditionQuestion(double number1, double number2) Constructs an addition question with specified numbers. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckAnswer(String givenAnswer) Checks the provided answer for correctness.voidshow()Displays the addition question.Methods inherited from class SolvishR.Question
getCorrectAnswer, getGivenAnswer, isAnswered, isCorrect
-
Constructor Details
-
AdditionQuestion
public AdditionQuestion(double number1, double number2) Constructs an addition question with specified numbers.- Parameters:
number1- The first number.number2- The second number.
-
AdditionQuestion
public AdditionQuestion()Constructs a random addition question with numbers generated between 10 and 10000 (inclusive).
-
-
Method Details
-
checkAnswer
Checks the provided answer for correctness.- Specified by:
checkAnswerin classQuestion- Parameters:
givenAnswer- The answer provided by the user.- Throws:
NumberFormatException- If the provided answer is not a valid number.
-
show
public void show()Displays the addition question.
-