Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

please dont use chat gpt or other AI 1 0 5 .

Answered: 1 week ago