Create a MyTime class which is designed to contain objects representing times in 12-hour clock format. Eg: 7:53am, 10:20pm, 12:00am (= midnight), 12:00pm (= noon). You can assume the user will enter times in the format given by the previous examples. Provide a default constructor, a set method which is given a String (eg: “7:53am”), a getHours method, a getMinutes method and a boolean isAm method. Also provide a method for returning a string “morning”, “afternoon”, “evening” or “night” appropriate (in your opinion) to the time. Please see the NOTE below concerning input validation and exception

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

Create a MyTime class which is designed to contain objects representing times
in 12-hour clock format. Eg: 7:53am, 10:20pm, 12:00am (= midnight),
12:00pm (= noon). You can assume the user will enter times in the format
given by the previous examples.
Provide a default constructor, a set method which is given a String (eg:
“7:53am”), a getHours method, a getMinutes method and a boolean isAm
method. Also provide a method for returning a string “morning”, “afternoon”,
“evening” or “night” appropriate (in your opinion) to the time.
Please see the NOTE below concerning input validation and exception

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Passing Array as Argument
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT