nawamkihafahd

Untitled

Oct 5th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public class NumberDisplay
  2. {
  3. private int limit;
  4. private int value;
  5.  
  6. public NumberDisplay(int rollOverLimit)
  7. {
  8. limit = rollOverLimit;
  9. value = 0;
  10. }
  11. public int getValue()
  12. {
  13. return value;
  14. }
  15.  
  16.  
  17.  
  18. public String getDisplayValue()
  19. {
  20. if(value < 10)
  21. {
  22. return "0" + value;
  23. }
  24. else
  25. {
  26. return "" + value;
  27. }
  28. }
  29. public void setValue(int replacementValue)
  30. {
  31. if((replacementValue >= 0) && (replacementValue < limit))
  32. {
  33. value = replacementValue;
  34. }
  35. }
  36. public void increment()
  37. {
  38. value = (value + 1) % limit;
  39. }
  40. }
Add Comment
Please, Sign In to add comment