Commit 18c2a981 authored by Niro Karunakaran's avatar Niro Karunakaran

Add new file

parent 2514eb08
Pipeline #7197 canceled with stages
public class TestGeometricObject {
/** Main method */
public static void main(String[] args) {
// Declare and initialize two geometric objects
GeometricObject Obj1 = new Circle(5);
GeometricObject Obj2 = new Circle(9);
GeometricObject Obj3 = new Rectangle(6, 3);
GeometricObject Obj4 = new Rectangle(5, 2);
System.out.println("The two objects have the same area? " +
equalArea(Obj3, Obj4));
// Display circle
displayGeometricObject(Obj3);
// Display rectangle
displayGeometricObject(Obj4);
}
/** A method for comparing the areas of two geometric objects */
public static boolean equalArea(GeometricObject object1,
GeometricObject object2) {
return object1.getArea() == object2.getArea();
}
/** A method for displaying a geometric object */
public static void displayGeometricObject(GeometricObject object) {
System.out.println();
System.out.println("The area is " + object.getArea());
System.out.println("The perimeter is " + object.getPerimeter());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment