001 /** This class tests your implementation of the Numeric interface, using
002 * a main function. The version here is just to get you started.
003 * The graders will actually do a more rigorous test of your implementation,
004 * so you should extend this file yourself to test that everything is
005 * really working to your satisfaction.
006 */
007
008 public class NumericTest {
009
010 /** Print "s: n" using System.out.println.
011 * The Numeric object n is printed as a long and also using toString.
012 * Typically used to print the answer of a test.
013 */
014
015 public static void printit(String s, Numeric n) {
016 System.out.println(s + ": " + n.longValue() + " " + n);
017 }
018
019 /** Test the RussianDoll implementation of Numeric. */
020
021 public static void main(String[] args) {
022 Numeric n1 = RussianDoll.valueOf(20L);
023 Numeric n2 = RussianDoll.valueOf(7L);
024 printit("20", n1);
025 printit(" 7", n2);
026 printit("sum", n1.add(n2));
027
028 Numeric[] qr = n1.divideAndRemainder(n2);
029 printit(" quotient", qr[0]);
030 printit(" remainder", qr[0]);
031 }
032 }