====== Fraction class instance add method ====== * Use the original [[cs176/501b/objects_in_methods_objects_as_class_fields_the_arraylist_class|Fraction]] class example as a starting point. * In the original //Fraction// class example, the //addFraction// and //subtractFraction// methods were static methods in //TestFraction//. * In the //Fraction2// BlueJ project, make the //addFraction// and //subtractFraction// methods instance methods of the //Fraction// class. * This is the new way we want to be able to work with //Fraction// Class objects: // // Code that goes in TestFraction.java: // Fraction f1 = new Fraction( 5, 8 ); Fraction f2 = new Fraction( 1, 9 ); Fraction f3 = new Fraction(); // This time, addFraction is an instance method of the Fraction // class, so we use the object f3's addFraction() method, i.e., // f3.addFraction(). f3.addFraction( f1, f2 ); // f3 holds the result of 5/8 + 1/9 System.out.println( f1 + " + " + f2 + " = " + f3);