COMP2247 - Algorithms and Data Structures

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Interface Geometry Program
ThreeDimensionalShape.java
Cube.java
Cylinder.java
GeometryClient.java




Geometry Program With Interface


Description

This program incorporates OOP Interface concept to design classes to represent different three dimensional shapes such as cube, cylinder, Cone, and etc.

An interface called ThreeDimensionalShape is used to declare abstract methods.

calculateArea()

calculateVolumn()

Classes such as Cube or Cylinder or Cone implements the interface.

Therefore, they must override the abstract methods declared in the interface.



Associated Concepts:

OOP - Interface

Algorithm:

Class diagrams:



Client program:

The client program uses the interface reference variables to refer to the actual objects.

It then uses the interface variables to invoke the objects' methods.

Source Code

Interface ThreeDimensionalShape



Cube class