Advertisement
Guest User

Alarm

a guest
Sep 21st, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1.  
  2. /**
  3. * Write a description of class Alarm here.
  4. *
  5. * @author Francois Argent
  6. * @version 1.0
  7. */
  8. public class Alarm
  9. {
  10.  
  11. private ClockDisplay12 time;
  12. private boolean isSet = false;
  13.  
  14. /**
  15. * Creates a new Alarm object, with a default time of
  16. * 12:00 a.m. with the alarm off.
  17. */
  18. public Alarm()
  19. {
  20. time = new ClockDisplay12();
  21. }
  22.  
  23. /**
  24. * Creates a new Alarm object with a specified time.
  25. */
  26. public Alarm(int hour, int minute, String amPm, boolean set)
  27. {
  28. time = new ClockDisplay12(hour, minute, amPm);
  29. isSet = set;
  30. }
  31.  
  32. /**
  33. * Sets the clock's time to another specified time.
  34. */
  35. public void setTime(int hour, int minute, String amOrPm)
  36. {
  37. time.setTime(hour, minute, amOrPm);
  38. }
  39.  
  40. /**
  41. * Turns on the alarm.
  42. */
  43. public void turnOn()
  44. {
  45. isSet = true;
  46. }
  47.  
  48. /**
  49. * Turns off the alarm.
  50. */
  51. public void turnOff()
  52. {
  53. isSet = false;
  54. }
  55.  
  56. /**
  57. * Returns the current time on the clock.
  58. */
  59. public String getTime()
  60. {
  61. return time.getTime();
  62. }
  63.  
  64. /**
  65. * Returns true if the alarm is set, false if it isn't set.
  66. */
  67. public boolean isSet()
  68. {
  69. return isSet;
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement