Question: In Jva, you will create a simple abstract data type (ADT) called IntTrackMinMax that takes integers one at a time and keeps track of the
In Jva, you will create a simple abstract data type (ADT) called IntTrackMinMax that takes integers one at a time and keeps track of the minimum and maximum values.
Here is the API for this ADT
constructor IntTrackMinMax()
check void check(int i) compares i to the current minimum and maximum values and updates them accordingly
getMin int getMin() returns the minimum value provided to check() so far
getMax int getMax() returns the maximum value provided to check() so far
toString String toString() returns the string "[min,max]"
toString():
Your implementation of toString() should return a string in the format "[min,max]" where min and max are the current minimum and maximum values.
For example, given this series of calls
IntTrackMinMax tmm = new IntTrackMinMax();
tmm.check(0);
tmm.check(5);
tmm.check(-5);
then tmm.getMin() should return -5, tmm.getMax() should return 0, and tmm.toString() should return "[-5,0]".
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
