Add an alarm feature to the Clock class of Exercise P9.1. When setAlarm(hours, minutes) is called, the

Question:

Add an alarm feature to the Clock class of Exercise P9.1. When setAlarm(hours, minutes) is called, the clock stores the alarm. When you call getTime, and the alarm time has been reached or exceeded, return the time followed by the string "Alarm" (or, if you prefer, the string "\u23F0") and clear the alarm. What do you need to do to make the setAlarm method work for WorldClock objects?

Data from Exercise P9.1.

Implement a class Clock whose getHours and getMinutes methods return the current time at your location. (Call java.time.LocalTime.now().toString() or, if you are not using Java 8, new java.util.Date().toString() and extract the time from that string.) Also provide a getTime method that returns a string with the hours and minutes by calling the getHours and getMinutes methods. Provide a subclass WorldClock whose constructor accepts a time offset. For example, if you live in California, a new WorldClock( 3) should show the time in New York, three time zones ahead. Which methods did you override? (You should not override getTime.)

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: