Section 11 -- April 10-11

This is an optional exercise. Work on this exercise only if you have done most of Project 5.

Implement the functionality of a radio alarm clock. Write a class RadioAlarmClock that implements an alarm clock with 2 bandwidth radio and a buzzer option alarm. The two bandwidth should not overlap. The class should have the following fields:

You should implement the following constructors and methods:

To get the system time assume that the existence of two methods that can be easily implemented using class Date from package java.util:

  • private void setTimeStamp() - this method sets time stamp that
  • private long getTimeElapsed() - this methods returns the time in milliseconds that elapsed from the time stamp previously set

The RadioAlarmClock has two constructors one that initializes the radio at midnight and one that uses a preset time to initialize the clock. The bandwidths should be initialized in the constructor and cannot be changed later. The "getTime" function should return human readable string representing the current time of the clock. (Hint: to measure it get the time elapsed from the time you last set the time). Also be careful that the time wraps at midnight, assume the 24 hour representation. The format of the string is "hh:mm:ss".

To keep things simple the bandwidth don't have to be real bandwidth but intervals on the real line and you don't have to implement the "wake up function".