Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java public class TheTime { private int hour; private int minute; private int second; /*Please add two constants below*/ /*private ...;*/ /*private ...;*/ /*Modify the

Java

image text in transcribed

public class TheTime { private int hour; private int minute; private int second; /*Please add two constants below*/ /*private ...;*/ /*private ...;*/ /*Modify the constructor so that increments when a valid time is created*/ public TheTime(int hour, int minute, int second) { this.hour = hour; this.minute = minute; this.second = second; /*...;*/ } /*Please add the private variable that records the number of valid TheTime objects created during the runtime, * and its corresponding getter method*/

/*private ...;*/

/*public ... get... { ... }*/ /*Setters and Getters*/ public int getHour() { return hour; } public void setHour(int hour) { this.hour = hour; } public int getMinute() { return minute; } public void setMinute(int minute) { this.minute = minute; } public int getSecond() { return second; } public void setSecond(int second) { this.second = second; } /*Please fill in the following blanks*/ /*public ... isValidTime() { ... }*/ /*public TheTime nextsecond() { ... } */

/*public ... isEqual(TheTime t) { ... }*/ //toString /*public ... toString() { }*/

Enhance the TheTime class by adding following methods and variables to their designated section in the class 1. Two private constants that models the maximal numerical value of hour, and minutes/second 2. isValidTime() method that returns a boolean true if the time is valid and false otherwise. Use the defined constant in the method. 3. A private variable that records the number of valid TheTime objects created during the runtime, and its corresponding getter method. 4. toString() method that return the time with the format of HH:MM:SS, as well as if the time is valid. Numbers that are less then 10 should have a leading zero, eg: 09:30:02 5. Modify the constructor so that the variable defined in step 3 increments when a valid time is created, otherwise print out a message to user to reassignment valid values 6. isEqual The Time t) method that returns if the times are equal 7. nextsecond() method that returns next second of the current time. If the hour goes over 23, the next second should be 00:00:00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions