Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NumberDisplay
- {
- private int limit;
- private int value;
- public NumberDisplay(int rollOverLimit)
- {
- limit = rollOverLimit;
- value = 0;
- }
- public int getValue()
- {
- return value;
- }
- public void setValue(int replacementValue)
- {
- if((replacementValue >= 0) && (replacementValue < limit))
- {
- value = replacementValue;
- }
- }
- public String getDisplayValue()
- {
- if(value < 10)
- {
- return "0" + value;
- }
- else
- {
- return "" + value;
- }
- }
- public void increment()
- {
- value = (value + 1) % limit;
- }
- }
Add Comment
Please, Sign In to add comment