Question: USING JAVA Class name Cntr -count : int -min : int -max : int +Counter() +Counter(c: int, mn: int, mx: int) +Counter(c: int) +setCount(c: int)
USING JAVA
Class name Cntr
-count : int
-min : int
-max : int
+Counter()
+Counter(c: int, mn: int, mx: int)
+Counter(c: int) +setCount(c: int) : void
+getCount() : int +setMin(mn: int) : void
+getMin() : int +setMax(mx: int) : void
+getMax() : void +increment() : void
+decrement() : void
The default value for all field values is 0.
The min and max values determine the valid interval for the count value. If both values are 0, then no interval exists and the count value is unrestricted.
If an interval exists, the count value should not be outside the range of the interval. If any operation is attempted that would cause the count to be outside the interval, a message indicating the issue should be displayed and the change should not be made.
The min value must always be lower than the max value. If any operation is attempted that would cause this not to be true, a message indicating the issue should be displayed and the change should not be made.
The max value must always be higher than the min value. If any operation is attempted that would cause this not to be true, a message indicating the issue should be displayed and the change should not be made.
The increment method should increase the count value by 1 and The decrement method should decrease the count value by 1.
write a demo class to test your design.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
