nawamkihafahd

Untitled

Oct 5th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. public class ClockDisplay {
  2. private NumberDisplay hours;
  3. private NumberDisplay minutes;
  4. private String displayString;
  5.  
  6. public ClockDisplay()
  7. {
  8. hours = new NumberDisplay(24);
  9. minutes = new NumberDisplay(60);
  10. updateDisplay();
  11.  
  12. }
  13.  
  14. public ClockDisplay(int hour, int minute)
  15. {
  16. hours = new NumberDisplay(24);
  17. minutes = new NumberDisplay(60);
  18. setTime(hour, minute);
  19.  
  20. }
  21.  
  22. public void timeTick()
  23. {
  24. minutes.increment();
  25. if(minutes.getValue() == 0)
  26. {
  27. hours.increment();
  28.  
  29. }
  30. updateDisplay();
  31. }
  32.  
  33. public void setTime(int hour, int minute)
  34. {
  35. hours.setValue(hour);
  36. minutes.setValue(minute);
  37. updateDisplay();
  38. }
  39.  
  40. public String getTime()
  41. {
  42. return displayString;
  43. }
  44.  
  45. private void updateDisplay()
  46. {
  47. displayString = hours.getDisplayValue() + ":" + minutes.getDisplayValue();
  48. }
  49.  
  50. }
Add Comment
Please, Sign In to add comment