|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Counter
public class Counter
Constructor Summary | |
---|---|
Counter()
Constructor for the Counter class, with initial value 0 and limit 12. |
|
Counter(int limit)
Constructor for the Counter class, with initial value 0 and given limit. |
Method Summary | |
---|---|
int |
getValue()
return the value of the Counter. |
static void |
main(java.lang.String[] args)
A main program to test the counter. |
void |
reset()
Resets the value of the Counter to 0 |
void |
set(int newValue)
Sets the value of the Counter to newValue. |
void |
tick()
Increment the value of the Counter, wrapping back to 0 when it reaches limit. |
java.lang.String |
toString()
returns a String representation with at least 2 digits, padding with a leading 0 if necessary. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Counter()
public Counter(int limit)
limit
- - the upper bound for the counterMethod Detail |
---|
public void tick()
public void set(int newValue)
newValue
- the value to reset the counter topublic void reset()
public int getValue()
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |