0% found this document useful (0 votes)
55 views1 page

Inner Classes

The document describes an alarm clock program with classes Clock and Timer. Clock has an inner class Timer that checks if the current time matches the alarm time, activating the alarm. When activated, the alarm displays a message for 5 seconds. The alarm can be acknowledged, erasing it, or erased by the user. The user can also modify an existing alarm. A TestClock class tests the program by creating a Clock object and setting an alarm.

Uploaded by

nu_am_chef_azi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views1 page

Inner Classes

The document describes an alarm clock program with classes Clock and Timer. Clock has an inner class Timer that checks if the current time matches the alarm time, activating the alarm. When activated, the alarm displays a message for 5 seconds. The alarm can be acknowledged, erasing it, or erased by the user. The user can also modify an existing alarm. A TestClock class tests the program by creating a Clock object and setting an alarm.

Uploaded by

nu_am_chef_azi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Inner classes

Problem 1

Write a program that simulate the functionality of an alarm clock. The program should implement
the classes from the next diagram:

These classes fulfill the following requirements:


- when a clock is created, the clock start time is set.
- it is possible to set the alarm time of the clock.
- the Timer is a inner class of the Clock class and verifies if the current time is equal to the
alarm time. In the affirmative case, the timer activates the alarm.
- an activated alarm is acknowledged by displaying a message to console for a period of five
seconds.
- acknowledgment of an alarm leads to the alarm being erased.
- an alarm can be also erased by the user.
- the user can also modify an existed alarm.

In order to test the functionality of the classes, write a TestClock class the creates an object from the
Clock class and set the alarm.

You might also like