3. The interface Range is defined below: public interface Range { void setLimits(int x, int y); int getNumber(); } Implementations of Range should exhibit the following behaviour: • The setLimits method should store its parameter values somewhere to serve as the lower and upper limits of the range appropriately. • A call to getValue should return an integer that is always greater than or equal to the lower limit and less than or equal to the upper limit. The class RandomInteger is an implementation of the interface Range. It also has the following features: • It has two fields of int type, low and high, to record the lower and upper limits of the range, respectively. • It has single constructor method that takes two integers and stores them in the appropriate fields. Note: You should make use of the setLimits method. • A call to the method getNumber should return a random number that is always within the range, i.e. greater than or equal to the lower limit and less than or equal to the upper limit. Define the class RandomInteger in full.
3. The interface Range is defined below:
public interface Range
{
void setLimits(int x, int y);
int getNumber();
}
Implementations of Range should exhibit the following behaviour:
• The setLimits method should store its parameter values somewhere to serve as the
lower and upper limits of the range appropriately.
• A call to getValue should return an integer that is always greater than or equal to the
lower limit and less than or equal to the upper limit.
The class RandomInteger is an implementation of the interface Range. It also has the following
features:
• It has two fields of int type, low and high, to record the lower and upper limits of the
range, respectively.
• It has single constructor method that takes two integers and stores them in the
appropriate fields. Note: You should make use of the setLimits method.
• A call to the method getNumber should return a random number that is always
within the range, i.e. greater than or equal to the lower limit and less than or equal to the
upper limit.
Define the class RandomInteger in full.
Step by step
Solved in 2 steps with 2 images