Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider a Time class that represents a point in time, such as 9 a . m . or 3 : 3 0 p . m
Consider a Time class that represents a point in time, such as am or : pm Complete the implementation of the following two constructors for the Time class in which the time is stored as an integer that represents the number of minutes since midnight. public class Time
private int minutesSinceMidnight;
Initializes a Time object to represent midnight.
public Time
Your code goes here
Initializes a Time object to represent the given time.
@param hours the hours component of the time:
@param minutes the minutes component of the time:
@param period a string indicating the period of the day: am or pm
public Timeint hours, int minutes, String period
Your code goes here
Returns the hour component of the time.
@return the hours as a value between
public int getHours
int hours minutesSinceMidnight ;
if hours hours hours ;
else if hours hours ;
return hours;
Returns the minutes component of the time.
@return minutes as a value between
public int getMinutes
return minutesSinceMidnight ;
Return the period of the day.
@return a String indicating ampm "noon" or "midnight"
public String getPeriod
if minutesSinceMidnight return "midnight";
else if minutesSinceMidnight return "noon";
if minutesSinceMidnight return am;
else return pm;
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