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

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 DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/11/2011 for the course EE 3206 taught by Professor Cwting during the Spring '07 term at City University of Hong Kong.

Page1 / 2

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online