Question
/** This class models a tally counter. */ public class Counter { private int value; private int max; public void setLimit(int maximum) { max =
/**
This class models a tally counter.
*/
public class Counter
{
private int value;
private int max;
public void setLimit(int maximum)
{
max = maximum;
}
/**
Gets the current value of this counter.
@return the current value
*/
public int getValue()
{
return value;
}
/**
Advances the value of this counter by 1.
*/
public void count()
{
//-----------Start below here. To do: approximate lines of code = 4
// increments value by 1. if value exceeds limit, print "Limit Exceeded" and reset value to 0
//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.
}
/**
Resets the value of this counter to 0.
*/
public void reset()
{
value = 0;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started