Published using Google Docs
OOP 9 - Inheritance (Buildings)
Updated automatically every 5 minutes

OOP 9 - Inheritance

Note to Couprie - New for next year 2018/19

This assignment needs a few additions

Imagine all the rectangles from your Geometry assignment represent buildings.  You will have 3 types of buildings:

Read this tutorial on Inheritance: https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html 

Subclass 1: Pyramid (60%)

Add a Pyramid class to your Geometry project that extends (is subclass of) Rectangle.  Pyramids will use the same methods and instance variables as Rectangle with one exception:  The formula for the volume of a pyramid is * width*length*height.  

Important note: You must change the private variables in your Rectangle class to either public or protected.  If you do not, you can not use those variables in the subclass.

Main Class

Create a new class called OOP8_InheritanceMain.  Copy as much code as you need from the original main class, then:

Subclass 2: House (40%)

Add a House class to your Geometry project that extends (is subclass of) Rectangle.  Houses will use the same methods and instance variables as Rectangle with a few exceptions:

Back in Main

Create 2 new houses and test that the area methods print both the area of the house and the yard You do not need to use the volume method for your houses.

Something to think about

How could we use these classes to build a program that would layout a new subdivision of a city?  What other classes of objects would we need?