Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java Write AlarmClockFormatter: :findAmVs Pm) One best practice related to the Single Responsibility Principle is that the responsibility for formatting the way an object should
java
Write AlarmClockFormatter: :findAmVs Pm) One "best practice" related to the Single Responsibility Principle is that the responsibility for formatting the way an object should look to a user should be separate from that object itself. Thus, an Alarmclock is not responsible for how it should look when we print the time to the console. Instead, we are using an AlarmClockFormatter class for that responsibility. Note that it is in the views package, not the model package. The findAmVs Pm() is method that determines if a clock currently has a morning ("AM") time or an afternoon/evening ("PM") time. 14. Read the specification of this method. 15. Complete the body of findAmVs Pm () a. Enforce the precondition b. Write an if-statement that returns "AM" if the clock's time is currently before 12 hours and returns "PM" otherwise. 16. Run the tests in TestFindAmVs Pm and fix any errors you find. 17. Write the findNormalizedHour() method a. Read the specification of this method b. Enforce the precondition c. Write an if-elseif-else statement that i. Returns hour-12 if the hour is great than 12 (i.e., afternoon) ii. Returns 12 if the hour is zero (i.e., midnight) iii. Returns hour otherwise d. Run the appropriate test classes and fix any errors you find. Write AlarmClockFormatter: :findAmVs Pm) One "best practice" related to the Single Responsibility Principle is that the responsibility for formatting the way an object should look to a user should be separate from that object itself. Thus, an Alarmclock is not responsible for how it should look when we print the time to the console. Instead, we are using an AlarmClockFormatter class for that responsibility. Note that it is in the views package, not the model package. The findAmVs Pm() is method that determines if a clock currently has a morning ("AM") time or an afternoon/evening ("PM") time. 14. Read the specification of this method. 15. Complete the body of findAmVs Pm () a. Enforce the precondition b. Write an if-statement that returns "AM" if the clock's time is currently before 12 hours and returns "PM" otherwise. 16. Run the tests in TestFindAmVs Pm and fix any errors you find. 17. Write the findNormalizedHour() method a. Read the specification of this method b. Enforce the precondition c. Write an if-elseif-else statement that i. Returns hour-12 if the hour is great than 12 (i.e., afternoon) ii. Returns 12 if the hour is zero (i.e., midnight) iii. Returns hour otherwise d. Run the appropriate test classes and fix any errors you find Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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