Object oriented program help
I am doing the following exercise:
a) Create a base class named Rectangle that contains length and width data members. From this class, derive a class named Box having an additional data member named depth. The method members of the base Rectangle class should consist of a constructor and have an area( ) method. The derived Box class should have a constructor and an override method named area( ) that returns the surface area of the box and a volume( ) method.
b) Include the classes constructed for Exercise 8a in a working Java program. Have your program call all of the member methods in each class and explain the result when the area method is called using two Box objects.
I have 3 separate files : Rectangle.java, Box.java, and UsingShapes.java
This is what I have so far:
UsingShapes.java (File which runs the other 2 files)
ANy suggestions for changes / additions? Thanks!
Re: Object oriented program help
looks like a good start....the Box class should extend Rectangle. Is there some specific question that you've got about this?
|All times are GMT +5.5. The time now is 08:36.|