Open the clock-display project in BlueJ and save it as a separate project to work on for this lab, e.g., lab5-alarm . Modify the ClockDisplay class to support a 12-hour clock as described in Exercise...

Open the clock-display project in BlueJ and save it as a separate project to work on for this lab, e.g.,lab5-alarm.

Modify the ClockDisplay class to support a 12-hour clock as described in Exercise 3.38, including 'am' or 'pm' in the display. You will need to think about how to do this, as there is more than one way. The only restriction is that you NOT modify the NumberDisplay class, and NOT modify the signatures of existing methods & constructors. Read Exercise 3.39 to get some ideas.


If you need help, watch thetextbook video note on solving the 12-hour clock exercise. However,you should spend significant time on this yourself before watching the video- this is a tricky exercise and your problem-solving skills will be improved by giving it your full effort before watching the video.


Now add an alarm clock feature to the clock (once again, update only the ClockDisplay class). You need to decide what additional fields are required. The clock should have the following public methods and functionality (
names & parameters should be exactly as shown
; consider this a spec from your client that needs to be met exactly).


turnAlarmOn(int hour, int minute)- turns the alarm on and sets it to the given time; hour may be an integerfrom XXXXXXXXXXrepresenting 12am - 11pm. (Note: This method does not ring the alarm, it just sets it to 'on' and the given time so that when the clock ticks to that time, it will ring.)


turnAlarmOff()- turns the alarm off. (When the alarm is off, it should not ring, even if theclock ticks to the alarm time.)


When the clock is created, the alarm should start in the 'off' position.


When the clock ticks to the set alarm time, if the alarm is turned on, an alarm should ring. You can simulate the ring with a print message.


If you have questions about how the alarm should function, post in the Lesson 4 Discussion topic and the instructor will answer. It is not uncommon in software development that a specification is unclear; asking clarifying questions is an important skill to develop.


Thesignaturesof theexisting methodsin ClockDisplay should alsonotbe changed, but you are welcome to update theimplementationof existing methods (and you will need to do so in order to add the alarm function).


As usual, update theclassheader Javadoc comment block andinclude an up-to-date method header Javadoc comment.


As usual, adhere to Java style guidelines as described in Appendix J.


Test your code thoroughly! Make sure that each tick of the clock works as expected. This can be tricky, so spend some time thinking about test cases that cover all the relevant scenarios. Use the Inspector in BlueJ to examine the object's fields as you test.


When you have completed the assignment, create a jar file of your project.


While the project is open in BlueJ, choose Project->Create Jar File...


Ensure that the "Include source" check box is checked



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here