For the public void setValue(int newcount) how do I make it so the value the other program sends is used to set the newcount? Also I have to do this "If the newcount < zero or > maxValue, do nothing."
private int maxValue;
private int count;
/**
* Constructor for objects of class Counter
*/
public Counter(int maxValue)
{
maxValue = 0;
}
public void decrement()
{
if (count == maxValue)
{
count = maxValue;
}
else
{
--count;
}
}
public int getValue()
{
return maxValue;
}
public void increment()
{
if (count == maxValue)
{
count = 0;
}
else
{
++count;
}
}
public void setValue(int newcount)
{
}
public String toString()
{
return "Counter{" + "maxValue=" + maxValue + '}';
}
}