16.12. NumberGroup - Part B¶
Part b. A range represents a number group that contains all (and only) the integers between a minimum value and
a maximum value, inclusive.
Write the Range
class, which is a NumberGroup
. The Range
class represents the group of int
values that range from a given minimum value up through a given maximum value, inclusive. For example, the declaration NumberGroup range1 = new Range(-3, 2);
represents the group of integer values -3, -2, -1, 0, 1, 2.
Write the complete Range
class. Include all necessary instance variables and methods as well as a constructor that takes two int
parameters. The first parameter represents the minimum value, and the second parameter represents the maximum value of the range. You may assume that the minimum is less than or equal to the maximum. Write the contains method which returns true or false if a given int argument is within the range set up by the constructor.
16.12.1. Try and Solve It¶
Complete the class Range
below with instance variables, a constructor, and a contains method.