Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a java class named TimeType with three private integer data fields named hours, minutes, and seconds, and implement the following public methods: TimeType()

1. Create a java class named TimeType with three private integer data fields named hours, minutes, and seconds, and implement the following public methods: TimeType() no argument contructor. Sets all private data to 0. TimeType(int, int, int) constructor function. Set the private data according to the three parameters. The first parameter represents hours, the second minutes, and the third seconds. If any of the parameters are invalid, set all private data to 0. TimeType(TimeType) contructor function. Initializes the private data to the values stored in the TimeType parameter String toString() Returns the time stored in the object in the format HH:MM:SS AM/PM boolean Set(int,int,int) Sets the time in the object according to the three parameters. The first parameter represents hours, the second minutes, and the third seconds. If any of the parameters are invalid, does nothing and returns false. Otherwise, set the private data according to the three parameters and returns true. void Increase() Increases the time in the object by 1 SECOND. Adjust the minutes and hours as necessary void Decrease() Decreases the time in the object by 1 SECOND. Adjust the minutes and hours as necessary 2. After you have created and compiled the TimeType class, create a client Java application to test the TimeType class. This application, named TestTime, should do the following and display its results using a Scanner object: - Create a TimeType object called time1 using the default constructor. - Create a TimeType object called time2 initialized to 23 hours, 59 minutes, and 58 seconds - Create a TimeType object called time3 initialized with the values from the time2 object. - Write the values of time1, time2, and time3 on separate lines. - Attempt to set the time in time1 to 25 hours, 0 minutes, and 0 seconds. If successful, display the time in time1 otherwise display the message "Invalid Time". - Create a loop that will increase and write the time in time2 10 times. - Create a loop that will decrease and write the time in time2 10 times. As usual, include general comments, comment each variable and method, and format your code neatly. 

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

=+ How well do you think you could do your job?

Answered: 1 week ago