Circular Tally Counter Not Rolling Over
- by chris ward
I was practicing my java and was trying to make a simple counter with rollover at max, but for some reason it isn't rolling over. Any advice?
public class HandTallyCounter {
private int max;
private int count;
public HandTallyCounter(int max) {
this.max = max;
count = 0;
}
public void click() {
if (count++ > max) {
count = 0;
}
}
public int getCount() {
return count;
}
public void reset() {
count = 0;
}
}