Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement Time class and TimeTest class that tests all of your public methods in Time using in JUnit. The Time object represents a particular time
Implement Time class and TimeTest class that tests all of your public methods in Time using in JUnit.
The Time object represents a particular time of day such as 12:30 PM or 9:47 AM. You must ensure that all Time objects always have valid state as described in this document. Each Time object should have the following public behavior. Method Description Constructor that takes an hour and minute (integers) and a boolean value representing whether it is in the AM (false) or PM (true) time period. Time (hour, minute, PM) This static method accepts a string such as "12:03 PM" and converts it into a Time object, which is returned. Your code must break apart the string in order to extract the individual integers and values such as 12, 3, and "PM" to interpret their meaning. If the string is in an invalid format, such as missing a colon or AM/PM or number, or if anything else goes wrong, throw an I1legalArgumentException. fromString (str) Returns true if and only if o refers to a Time object with exactly the same state as this one; otherwise returns false equals (o) getHour , getMinute) Accessors for the time's hour and minute state. sPM () Returns true if this time occurs between 12:00 PM (noon) and 11:59 PM inclusive. Adjusts this time object forward in time by the given number of minutes (an integer). This might cause the object to wrap into the next hour or even wrap around to the next entire day. If the number of minutes is negative, throw an IllegalArgumentException. This method can be O(minutes) though it doesn't need to be shift (minutes) Returns a string for this time in HH:MM AM/PM format. The hours and minutes are always shown as two-digit numbers, with a colon between and a space between the time and the AM/PM period. For example, "04:53 AM" or "12:07 PM" toString () If any method or constructor is passed a parameter whose value is invalid, you should throw an IllegalArgumentException. In particular, you must enforce the following Time values should have valid numbers of hours (1-12) and minutes (0-59) For example, calling shift(120) on 11:30 AM should result in 01:30 PM. (NOT 11:150 AM!)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