Constructor Lab
Task 1
Add an appropriate constructor to each class that you defined in the previous lab. For example, add the constructor of the form public Book(String title, String author, int pages) to the Book class. Write code in a separate class to prompt the user for values for these properties, and use those values and the constructor that you have defined to instantiate an object of that class. Repeat for all the classes.
Task 2
AFTER YOU FINISH TASK 1, write a class named Fraction, which models a fraction. In the class, model the following properties and behaviors:
Private properties: numerator and denominator.
Constructor that accepts values for these properties. Thus, you could write Fraction f1 = new Fraction(1,2) to create the fraction f1 with the value one-half.
A method with the signature public String toString() which returns the String representation of a fraction. Imagine that your chosen string representation of a fraction has the form numerator/denominator. If you wrote System.out.println("f1 = "+ f1), this method would be invoked automatically to convert f1 to its string representation and the display would read f1 = 1/2.
A method with the signature public Fraction addTo (Fraction anotherFraction), which returns the sum of two fractions. Thus, if you had instantiated two Fraction objects, f1 and f2, you can use this method to compute their sum using the statement Fraction sum = f1.addTo(f2);
Test your class by creating two fraction objects, adding them and displaying the objects and their sum on the screen.