Question
NumberDisplay: Modify ClockDisplay to accommodate a 12-hour clock in addition to the 24-hour clock Rules: You must not change the storage from current 24-hour clock
NumberDisplay:
Modify ClockDisplay to accommodate a 12-hour clock in addition to the 24-hour clock Rules:
-
You must not change the storage from current 24-hour clock values
-
You must not modify NumberDisplay
To implement a 12-hour clock, modify the ClockDisplay class as follows:
-
add a private field boolean twelveHourDisplay that is initialized to false in the constructors.
-
add a method public void toggleDisplay() that flips/toggles the value of twelveHourDisplay (i.e. from true to false or false to true). The method should also call updateDisplay() so that the current display reflects the correct type of time (12-hour or 24-hour) .
a. Access type public b. Return type void c. Parameters none d. Logic toggle twelveHourDisplay and call updateDisplay()
-
modify the private void updateDisplay() method to set the display string to a 12-hour time (with a.m. and p.m.) if twelveHourDisplay is true. Think of cases on the 24-hour clock and how they translate into the 12-hour clock.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started