1. Create the java TimeType class (discussed in class & Chapter 8),
with three private integer data fields named hours, minutes,
and seconds, and implement the following public methods:
no argument contructor. Sets all private data to 0.
TimeType(int, int, int)
contructor function. Set the private data according to the
three parameters. The first paramter represents hours, the
second minutes, and the third seconds. If any of the
parameters are invalid, set all private data to 0.
contructor function. Initializes the private data to the
values stored in the TimeType parameter
Returns the time stored in the object in the format
Sets the time in the object according to the three
parameters. The first paramter 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.
Increases the time in the object by 1 SECOND
Decreases the time in the object by 1 SECOND
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
– 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
– Create a loop that will decrease and write the time in time2 10
As usual, include general comments, comment each variable and method, and format
your code neatly.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Start Assignment 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Assignment:
Create a new DateAndTime class that inherits from your TimeType class
and adds the following three private integer instance variables: month, day,
and year (and two arrays – see Notes below). Your class should implement the
1. DateAndTime() a no-argument constructor that sets the date to 01/01/1980 and
the hours, minutes and seconds to 0.
2. boolean setDate(int m, int d, int y)
If the year and month are valid, and the day is valid for the
given month, set the month, day, and year according to the
parameters supplied and return true. If any of the parameters
are invalid, this method should do nothing and return false.
3. void increaseDay()
increases the day by 1. Adjusts the month and year if necessary.
4. void decreaseDay()
decreases the day by 1. Adjusts the month and year if necessary.
5. String toString()
prints the date in the format Monthname day, year HH:MM:SS AM/PM
6. boolean isEqual(Date d)
return true if the Date object calling the method has the same
values as the Date object passed as a paramater, otherwise return
7. boolean leapYear(int yr)
returns true if the parameter yr is a leap year, otherwise returns
false. A leap year occurs in years whose last two digits are
evenly divisible by four, except for centenary years not divisible by 400
8. void increaseSecond()
increases the time by one second. Adjusts the date if necessary
9. void decreaseSecond()
decreases the time by one second. Adjusts the date if necessary
Assume the original TimeType class from assignment #4 contains 3 additional methods:
getSeconds(), getMinutes(), and getHours(). Each of these methods return the respective private instance variable.
These methods are necessary to implement increaseSecond() and decreaseSecond(). A complete working copy
of the TimeType class is available in the class folder/home2/classes/csi205/TimeType.class
In addition to the month, day, and year private instance variables, you should
create two one dimensional private instance variable arrays for the purpose of
printing the month names, and for validating the number of days in each month.
The first static final array of 12 String elements should hold the names of
each month and should be referenced by the toString() method to return the full
month name. The second array of 12 int elements should be referenced to
determine if the given day is valid for the current month. The days in each
month are: Jan 31, Feb 28, Mar 31, Apr 30, May 31 Jun 30, Jul 31, Aug 31,
Sep 30, Oct 31, Nov 30, Dec 31. You should use the leapYear() method to
determine if Feb. contains 28 or 29 days.
You should create your own test client to test the implementation of your
As usual, format your code neatly. You should comment each of your variables
and place comments before EACH method explaining its purpose.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more