Question
Please, I need help completing the java code on the right side of the photo and the instructions are on the left side of the
Please, I need help completing the java code on the right side of the photo and the instructions are on the left side of the photo. Thank you. I hope this helps, if not please let me know
public class AlarmClock {
private int hour; private int minutes; /** * Creates a new alarm clock set at midnight (00:00) * * @precondition none * @postcondition getHour()==0 AND getMinutes()==0 AND getSeconds()==0 * */ public AlarmClock() { this.hour = 0; this.minutes = 0; }
/** * Creates a new alarm clock with the time set at the given hours and minutes. * * @precondition 0 23) { throw new IllegalArgumentException("hour should be between 0 and 23"); } if (minutes 59) { throw new IllegalArgumentException("minutes should be be between 0 and 59"); } this.hour = hour; this.minutes = minutes; }
The findAmVs Pm() is method that determines if a clock currently has a morning ("AM") time or an afternoon/evening ("PM") time. 1. Read the specifications for this method. "Alarm ClockFormatter.java X 1 2. Complete the body of findAmVs Pm) a. Enforce the precondition b. Write code that returns "AM" if the clock's time is currently before 12 hours otherwise it returns "PM". 3. Run the tests in Test.FindAmVsPm and fix any errors you find. These tests are commented out. The findNormalizedHour() is a method that converts from a 24-hour format to a 12-hour format *Returns "AM" or "P" depending on the clock time. * @precondition clock = null @postcondition none * @param clock the clock - @return "AM" if the time is in the morning between midnight and 11:59), "P" otherwise * public String finden SPM(Alarmclock clock) { 17 TODO: replace the return statement with the code that implements this method return ""; } 1. Write the findNormalizedHour() method * Given an hour between and 23 (from 24-hour format), convert it to an hour appropriate for 12-hour format a. Read the specification of this method b. Complete the body of findAmVsPm) preconditioneStep 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