This lab was copied from Professor Horstmann.
1. Create a Scala project named TimeLab.
2. Add a package called time1 to this project.
3. Add an app called TestTime1 to the time1 package.
4. Here's the output produced by running TestTime1:
t1 = 3:45
t2 = 3:00
t1 < t2 = false
t1 minutes since midnight = 225
java.lang.IllegalArgumentException
5. Add a class to the time1 package called Time. Implement Time so that will make TestTime1 produce the desired output.
· As in Java, Scala classes inherit a toString method from the AnyRef class. You must override this method to customize the object-to-string conversion.
· In this version minutes and hours should be read-only integer fields. However, an IllegalArgumentException is thrown if hours < 0, minutes < 0, 23 < hours, or 59 < minutes.
1. Add a package called time2 to the project.
2. Add an app called TestTime2 to the time2 package.
3.
Here's the output produced by running TestTime:
t1 = 22:05
t2 = 20:10
t1 < t2 = false
t1 < t2 = true
java.lang.IllegalArgumentException
4. Add a class to the time1 package called Time. Implement Time so that will make TestTime produce the desired output.
· If we just turn the hours and minutes fields into variables, we won't get the desired error checking. Instead, we want to rename these fields h and m. Make them private var fields.
· Add the functions hours and minutes and setters hours_= and minutes_=.