/*============================================================================= | Assignment: Program #T01n19 : T01n18.java in two files. | Author: L. McCann | Sect. Leader: Self :-) | | Course: CSc 227 -- Program Design and Development | Instructor: L. McCann | Due Date: January 29, 2007 | | Description: This program has the same code as T01n18.java. The | difference is that in this version, the main() method is | in this file, while the Fraction class is now in the | Fraction.java file. The purpose is to show how easily | a Java program can be partitioned into separate files | to enable a useful general-purpose class to be easily | used by multiple applications. | | Just compile this file; Java will seek out a file in | the same directory named Fraction.class. If it doesn't | find one, it will look for Fraction.java and compile it. | | Deficiencies: The Fraction class is far from complete, and main() | doesn't come close to being a really good testing | program for Fraction. But that's OK; this is just a | demonstration program. *===========================================================================*/ public class T01n19 { public static void main (String [] args) { Fraction myFraction, // still hard to give these good names! myOtherFraction, anotherFraction, yetAnotherFraction; myFraction = new Fraction (3,4); myOtherFraction = new Fraction (2,3); System.out.println(myFraction.asDouble()); anotherFraction = myOtherFraction.multiplyBy(4); System.out.println(anotherFraction.asString()); yetAnotherFraction = myOtherFraction.multiplyBy(myFraction); System.out.println(yetAnotherFraction.asString()); } }