Package SolvishR
Class SubtractionQuestion
java.lang.Object
SolvishR.Question
SolvishR.SubtractionQuestion
Represents a question related to subtraction.
Extends the
Question class and provides functionality to generate subtraction questions with random numbers.- Version:
- 1.0
- Author:
- Adib Sakhawat
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a random subtraction question with numbers generated between 10 and 10000 (inclusive).SubtractionQuestion(double number1, double number2) Constructs a subtraction question with specified numbers. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckAnswer(String givenAnswer) Checks the provided answer for correctness.voidshow()Displays the subtraction question.Methods inherited from class SolvishR.Question
getCorrectAnswer, getGivenAnswer, isAnswered, isCorrect
-
Constructor Details
-
SubtractionQuestion
public SubtractionQuestion(double number1, double number2) Constructs a subtraction question with specified numbers.- Parameters:
number1- The minuend.number2- The subtrahend.
-
SubtractionQuestion
public SubtractionQuestion()Constructs a random subtraction question with numbers generated between 10 and 10000 (inclusive). The subtrahend is generated to be between 10 and the value of the minuend.
-
-
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 subtraction question.
-