// TestShape.java - Test the compareTo and equals methods
// Suzanne Balik, 11 Apr 2004
import java.text.*; //DecimalFormat
public class TestShape {
public static void main(String args[]) {
Triangle t = new Triangle(1, 4, 5);
Rectangle r = new Rectangle(2, 2, 5);
Circle c = new Circle(3, 4);
System.out.println("area of t: " + t.area());
System.out.println("area of r: " + r.area());
System.out.println("area of c: " + c.area());
System.out.println("t has same area as r: " +
t.equals(r));
System.out.println("t has same area as c: " +
t.equals(c));
if (t.compareTo(c) < 0)
System.out.println("t is smaller than c");
else
System.out.println("t is bigger than c");
}
}
/* PROGRAM OUTPUT:
eos% java TestShape
area of t: 10.0
area of r: 10.0
area of c: 50.26548245743669
t has same area as r: true
t has same area as c: false
t is smaller than c
*/