Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

public abstract class MathQuestion implements MathQuestionable { / / TODO: Declare private member integer constants x and y / / TODO: Define a default (

public abstract class MathQuestion implements MathQuestionable {
// TODO: Declare private member integer constants x and y
// TODO: Define a default (no parameters) constructor that assigns
// x to RANDOM.nextInt(MAX_LARGE)+1
// y to RANDOM.nextInt(MAX_SMALL)+1
// TODO: Define a parameterized constructor that accepts two integer values
// The first parameter must be assigned to x
// The second parameter must be assigned to y
// TODO: Define public accessor methods getX() and getY()
public String getQuestion(OperationType op){
return "What is "+ x +''+ op.getSymbol()+''+ y +'?';
}
}
class AdditionQuestion extends MathQuestion {
// This class definition should give you a basic idea for how to define the other
// operation classes. Keep in mind the other characteristics each operation might have.
public AdditionQuestion(){
super();
}
public AdditionQuestion(int px, int py){
super(px, py);
}
public String getQuestion(){
return super.getQuestion(OperationType.ADD);
}
public int getCorrectAnswer(){
return getX()+ getY();
}
}
class DivisionQuestion extends MathQuestion {
private static int _x = RANDOM.nextInt(MAX_LARGE)+1;
private static int _y = RANDOM.nextInt(_x)+1;
// TODO: Define default constructor to call parent class constructor and passing _x and _y as arguments
// You will also need to reassign new random values to both _x and _y as shown in the initial assignment statements
// TODO: Define a parameterized constructor that accepts two integers and passes these in a call to the parent constructor
// TODO: Define getQuestion that returns a String and makes a call to the parent getQuestion method.
// You will need to pass OperationType.DIVIDE as the argument
// TODO: Define getCorrectAnswer that returns an integer result of x / y (this is not as simple as it looks!)
}
class ExponentQuestion extends MathQuestion {
private static int _x = RANDOM.nextInt(MAX_BASE)+1;
private static int _y = RANDOM.nextInt(MAX_EXPONENT);
// TODO: Define default constructor to call parent class constructor and passing _x and _y as arguments
// You will also need to reassign new random values to both _x and _y as shown in the initial assignment statements
// TODO: Define a parameterized constructor that accepts two integers and passes these in a call to the parent constructor
// TODO: Define getQuestion that returns a String and makes a call to the parent getQuestion method.
// You will need to pass OperationType.EXPONENT as the argument
// TODO: Define getCorrectAnswer that returns an integer result of Math.pow(x, y)(this is not as simple as it looks!)
}
class ModuloQuestion extends MathQuestion {
private static int _x = RANDOM.nextInt(MAX_LARGE)+1;
private static int _y = RANDOM.nextInt(_x)+1;
// TODO: Define default constructor to call parent class constructor and passing _x and _y as arguments
// You will also need to reassign new random values to both _x and _y as shown in the initial assignment statements
// TODO: Define a parameterized constructor that accepts two integers and passes these in a call to the parent constructor
// TODO: Define getQuestion that returns a String and makes a call to the parent getQuestion method.
// You will need to pass OperationType.MODULO as the argument
// TODO: Define getCorrectAnswer that returns an integer result of x % y (this is not as simple as it looks!)
}
class MultiplicationQuestion extends MathQuestion {
private static int _x = RANDOM.nextInt(MAX_MULTIPLE)+1;
private static int _y = RANDOM.nextInt(MAX_MULTIPLE)+1;
// TODO: Define default constructor to call parent class constructor and passing _x and _y as arguments
// You will also need to reassign new random values to both _x and _y as shown in the initial assignment statements
// TODO: Define a parameterized constructor that accepts two integers and passes these in a call to the parent constructor
// TODO: Define getQuestion that returns a String and makes a call to the parent getQuestion method.
// You will need to pass OperationType.MULTIPLY as the argument
// TODO: Define getCorrectAnswer that returns an integer result of x * y (this is not as simple as it looks!)
}
class SubtractionQuestion extends MathQuestion {
private static int _x = RANDOM.nextInt(MAX_SMALL)+ MAX_SMALL +1;
private static int _y = RANDOM.nextInt(MAX_SMALL)+1;
// TODO: Define default constructor to call parent class constructor and passing _x and _y as arguments
// You will also need to reassign new random values to both _x and _y as shown in the initial assignment statements
// TODO: Define a parameterized cons
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students explore these related Databases questions