Inheritance principles

Jynx

Active member
Joined
Oct 20, 2007
Messages
44
Programming Experience
Beginner
Well I've reached the end of another chapter and I need to see how to do a couple applications. I posted the Console one already and now for the GUI based one.

For this project, you'll write a set of classes that use apply inheritance principles.

Write a class named Rectangle. This class should have data fields for:

* length
* width

Also provide the following methods:

* A way to get and set each of these fields
* a constructor that takes values to initialize the length and width fields
* a method that will return the area of the Rectangle (length times width)
* a ToString method that will return a description of the Rectangle as a String.

NOTE: Your program will not be drawing the Rectangle, only providing a way to represent it.

Once you have your Rectangle class working correctly, write a child class of Rectangle, named Box. This class should have one additional data field:

* height

Also provide the following methods:

* a way to get and set the value of height
* a constructor that takes values for length, width and height
* a method that returns the volume (length times width times height)
* a ToString method that returns a String representation of the Box
 
Last edited by a moderator:
Post the code you have so far, and be more specific what exactly you have problems with.
 
Honestly John, I don't even know where to start on this one, (I'm honest if anything). Thanks for fixing the formatting here as well. I started trying to write it based off what I read in the book. I think I'm making it harder than it is. I have no idea if this means I am to actually input the data and give results or just make classes that "Can" do what the project says with no actual GUI of any kind.
 
Last edited:
I watched the videos. I see what he's doing but I'm having a hard time applying it here. Thanks though for your help and I book marked that page.
 
Back
Top