+
DESIGN A CLASS NAMED CLOCK. THE CLASS CONTAINS...

DESIGN A CLASS NAMED CLOCK. THE CLASS CONTAINS...

Rating:
Rating
(0)
Author: Carol 96
Description:

Click link for more description

http://theperfecthomework.com/design-a-class-named-clock-the-class-contains-private-data-fields-for-starttime-and-stoptime-a-no-argument-constructor-that-initializes-the-starttime-to-the-current-time-a-method-named-start-that-resets-the-start/

DESIGN A CLASS NAMED CLOCK. THE CLASS CONTAINS PRIVATE DATA FIELDS FOR STARTTIME AND STOPTIME, A NO ARGUMENT CONSTRUCTOR THAT INITIALIZES THE STARTTIME TO THE CURRENT TIME, A METHOD NAMED START() THAT RESETS THE START

Design a class named Clock. The class contains private data fields for startTime and stopTime, a no argument constructor that initializes the startTime to the current time, a method named start() that resets the startTime to the given time, a stop() method that sets the endTime to the given time and a getElapsedTime() method that returns the elapsed time in seconds. Construct a Clock instance and return the elapsed time. Command line arguments should be used to send the start and end times. You should use the java.time classes.
Here is sample run: java TestClock 11:45:12 11:48:13 Elapsed time in seconds is: 181
My professor looked at my following code and said : ask the user to press a key that will place the computer time into the start variable and then ask the user to wait some time and then have him press a key and at that point the same method will get the new current time in the computer and assign it to the end variable. With the two different times of start and end, you should be able to use your getElapsedTime () method to work."
He wants some interactive code where the user is prompted as asked in his feedback.  WARNING:  my professor is picky and wants things done as asked.  I am just under a time crunch here and do not understand how to use LocalTime.now(); through prompting the user to do what he is asking.  I could figure it out if I had hours but I don't.
The code so far:
import java.time.LocalTime;// Makes the LocalTime class visibleimport java.time.Duration;// Makes the Duration class visible
/**** @author*/public class Homework4 {//program name  public class Clock {private LocalTime startTime;//start timeprivate LocalTime stopTime;//stop time  public Clock() {// gets the current time from the system clock in the default time-zonestartTime = LocalTime.now();


(more)
See More
Try a College Course Free

Sophia’s self-paced online courses are a great way to save time and money as you earn credits eligible for transfer to over 2,000 colleges and universities.*

Begin Free Trial
No credit card required

25 Sophia partners guarantee credit transfer.

221 Institutions have accepted or given pre-approval for credit transfer.

* The American Council on Education's College Credit Recommendation Service (ACE Credit®) has evaluated and recommended college credit for 20 of Sophia’s online courses. More than 2,000 colleges and universities consider ACE CREDIT recommendations in determining the applicability to their course and degree programs.

Tutorial