Java 2
Lab 5

Create new classes, Time and TimeTester, copying from your Chapter 4-6
listings.  Revise the TimeTester to use System.out.println, showing the time
and result in the same line.  


Improving the Time class


1.  Rewrite the toString method to have Time printed out as 2:30 or 18:05.      

2.  Rewrite the constructor using division, /, and the mod operator, %,  
as discussed in class, so that all times once constructed will have 
itsHour between 0 and 23 and itsMin between 0 and 59.  

3.  Overload the constructor to make a Time object given a number of 
positive or negative minutes.  The signature would be

public Time(int minutes)

so a new Time object constructed Time (384) would be printed out 6:24
and Time (-250) would be 19:50


Add the following methods to the Time class.  

4.
public Time subtract (Time that)        // returns a new Time object that is the 
        // difference of the two Time objects (the executor minus the parameter)
        
For example,  
2210 minus 1430 is 740. 
0720 subtract 1430 is 1650
If the difference is should not be negative, for example
330 subtract 1445 should be 1245.

5.
public int timeInMinutes()          //The executor tells the total number of 
                                    //minutes that have passed since midnight.
For example,
    8:45 would return 525
    20:15 would return 1215

When you submit your lab, use all the above as test data.  Run TimeTester and 
copy and paste the output in a comment below the main.


Extra Credit:  
Create a new class, BetterTime, by copying the Time class and making the 
following additions and changes:
    include the  data fields (instance variables)   int itsDay and int itsSecond
    revise both constructors so that going over 24 adds a day and 
        going negative subtracts a day
        revise the toString() method to print in the form:  
                day hour:min:second
    
    The day should be counted from the beginning of the year. It should be 
    able to handle subtracting from Jan 1 (itsday =1) and adding to 
    Dec 31 (itsDay=365).  Thoroughly test your class with the BetterTimeTester 
    class.  Copy your output on the bottom of the BetterTimeTester class.