{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

tut05 - EE3206/EE5805 Java Programming Application Tutorial...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
EE3206/EE5805 Java Programming & Application Tutorial 5 – Inheritance, Abstract and Interface 1. Given the abstract class Polygon , write another class Octagon to extend the Polygon . You should implement all the abstract methods in Polygon and provide a constructor to initialize the length of side. The area of an octagon can be calculated by: (2 4/ 2)* * area length length = + 2. Write an interface Colorable and provide two abstract methods: String getColor() void setColor(String color) 3. Write a class ColorableOctagon to extend the Octagon and implement the interface Colorable . You should provide a constructor to initialize the color of an instance of ColorableOctagon . 4. Write a driver class TestColorableOctagon . This class provides two static methods: public static boolean compareColor(Colorable obj1, Colorable obj2) public static boolean compareArea(Polygon obj1, Polygon obj2) The method returns true when the input parameters have same attribute. In the main method, create an array to store some instances of
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon