Question: This is a Java programming assignment and I want help with the Time class. See below for assignment details: For this question you must write

This is a Java programming assignment and I want help with the Time class. See below for assignment details:

For this question you must write a java class called Time and a client class called TimeClient. The partial Time class is given below. (For this assignment, you will have to submit 2 .java files: one for the Time class and the other one for the TimeClient class and 2 .class files associated with these .java files. So in total you will be submitting 4 files for part b of this assignment.)

// A Time stores time in ISO 8601 format keeping hours, minutes, and seconds.

public class Time {

private int hours; // in range [0,23]

private int minutes; // in range [0,59]

private int seconds; // in range [0,59]

// constructs a new Time with the given hours, minutes, and seconds

public Time(int hours, int minutes, int seconds) {

setHours(hours);

...

}

// returns the fields' values

public int getHours()...

public int getMinutes()...

public int getSeconds()...

// sets fields values implementing appropriate input validation.

// if input is not valid sets value to zero.

public void setHours(...) ...

public void setMinutes(...) ...

public void setSeconds(...) ...

public void setTime(int hours, int minutes, int seconds) ...

// Advance by 1 second and return this instance Time nextSecond() ...

Time previousSecond() ...

// returns a string such as Time is 14:25:43

public String toString(){ ... }

Write the client class TimeClient that creates an object of class Time and initializes its with time 23:59:59. Print out the time using toString method. Advance the time by 10 seconds using nextSecond method and print the time. Decrease the time by 20 seconds using previous time method and print the time again. Set the time to 25:00:00, and print the time. Set the time to 12:40:86 and print the time. When you execute the TimeClient file you result should look like:

Creating time of 23:59:59

The object time is 23:59:59

Advancing time by 10 seconds

The object time is 00:00:09

Decreasing time by 20 seconds

The object time is 23:59:49

Setting time to 25:00:00

The object time is 00:00:00

Setting time to 12:40:86

The object time is 12:40:00

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!