Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

How could an organization's culture be used as a control mechanism?

Answered: 1 week ago