Allan Didier

Shapes

Goals

Students will demonstrate their ability to use abstract classes and interfaces. 

Skills

  • Abstract classes
  • Interfaces

Program Details

Create a program with the following abstract classes and interfaces.

  1. Abstract class Shape
    1. Abstract method: float getCircumference();
  2. Interface twoD
    1. Method: float getArea()
  3. Interface threeD
    1. Method: float getVolume()
    2. Method: float getSurfaceArea()
  4. Interface parallelogram
    1. Method: float getSides: returns all four sides of the parallelogram
    2. Method: float getAngles: returns the two angles inside the parallelogram.
  5. Interface ellipse
    1. Method: float getAxes: returns both the horizontal and vertical axes of an ellipse
  6. Interface triangle
    1. Method: float getHeight
    2. Method: float getWidth
    3. Method: float getSides: returns all three sides of the triangle.
  7. Classes
    1. rectangle extends Shape implements 2D and parallelogram
    2. square extends rectangle
    3. rhombus extends Shape implements 2D and parallelogram
    4. rightTriangle extends Shape implements 2D and triangle
    5. isosceleslTriangle extends Shape, implements 2D and triangle
    6. equilateralTriangle extends Shape, implements 2D and triangle
    7. Circle extends Shape implements 2D and ellipse
    8. Oval extends Shape implements 2D and ellipse
    9. Cube extends Square implements 3D
    10. Cylinder extends Circle implements 3D
  8. Main Program
    1. Creates the 10 shapes.
    2. Outputs the 10 shapes values as appropriate (length, width, height, circumference, area, surface area, and/or volume)

Resources

Edhesive Term 2

Lesson 9: Abstract methods and classes

Lesson 11: Interfaces