Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In java please a. Using UML notation, design a class called MyTime in Microsoft Word to represent an instance of time. The class contains: a.
In java please
a. Using UML notation, design a class called MyTime in Microsoft Word to represent an instance of time. The class contains: a. Data fields hour, minute and second to represent time. b. A no-arg constructor to create a Time object with values of current time. c. A constructor to construct a Time object with specified values for hour, minute and second. d. A constructor to construct a Time object with specified elapsed time since midnight January 11970 in milliseconds. The values of the data fields will represent this time. e. Three getter methods for the data fields. f. A method called setTime(long elapsedTime) that sets a new time for the object using elapsed time. Here is code for the constructor in part (d) public MyTime (long elapsedTime) \{ setTime (elapsedTime); f And here is code for the setTime() method public void setTime(long elapsedTime) \{ // Obtain the total seconds since the midnight, Jan 1,1970 long totalseconds = elapsedTime / 1000 ; // Compute the current second in the minute in the hour c. Write a test program that will: - Create three MyTime objects as shown below. - After creating each MyTime object, display the time in format Hour:minute:second MyTime time1 = new MyTime () / /display timel MyTime time2 = new MyTime (555550000); / /display timel MyTime time3 = new MyTime (5,23,55); / /display time1Step 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