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.
- Abstract class Shape
- Abstract method: float getCircumference();
- Interface twoD
- Method: float getArea()
- Interface threeD
- Method: float getVolume()
- Method: float getSurfaceArea()
- Interface parallelogram
- Method: float getSides: returns all four sides of the parallelogram
- Method: float getAngles: returns the two angles inside the parallelogram.
- Interface ellipse
- Method: float getAxes: returns both the horizontal and vertical axes of an ellipse
- Interface triangle
- Method: float getHeight
- Method: float getWidth
- Method: float getSides: returns all three sides of the triangle.
- Classes
- rectangle extends Shape implements 2D and parallelogram
- square extends rectangle
- rhombus extends Shape implements 2D and parallelogram
- rightTriangle extends Shape implements 2D and triangle
- isosceleslTriangle extends Shape, implements 2D and triangle
- equilateralTriangle extends Shape, implements 2D and triangle
- Circle extends Shape implements 2D and ellipse
- Oval extends Shape implements 2D and ellipse
- Cube extends Square implements 3D
- Cylinder extends Circle implements 3D
- Main Program
- Creates the 10 shapes.
- 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