Results 1 to 2 of 2
Thread: using inheritance
- 10-18-2011, 12:29 AM #1
Senior Member
- Join Date
- Feb 2011
- Posts
- 235
- Rep Power
- 3
using inheritance
I have this problem for homework, and do not understand why you would want to create an extra file for doing something else... why not just import it? is it so nobody can edit, and mess up your program? or does it make it easier to modify/tact on code to your program? here is my problem:
"Design and implement a set of ciasses that define a series of
three-dimensional geometric shapes. For each, store fundamental data about their size and provide methods to access and modify this data. In addition, provide appropriate methods to compute each shape's circumference, area, and volurne. In your design, consider how shapes are related and thus where inheritance can be implemented. Greate a mai n driver dass to instantiate several shapes of differing types and exercise the behavior you provided."
I understand how to solve it. It's just trying to figure out what I would put in my interface class.
Thanks in advance.
- 10-18-2011, 02:38 AM #2
Re: using inheritance
This makes no sense. If you import something then you are doing it from a different class/file. Once reason for having separate classes is so you can represent a single object. If you need a Fork and a Dog then it makes no sense having all the code in one class. Another reason is for easy of maintenance. If you have a program that consists of 10,000 lines of code, having it all in one class would make updates a nightmare.
Generally you place common behaviour in the interface. For example all shapes have a volume but the calculations are all different. Therefore you can place a method called volume in the interface and then each class that implements the interface MUST have a concrete method that actually performs the calculation.what I would put in my interface class
Similar Threads
-
using inheritance
By senca in forum New To JavaReplies: 4Last Post: 08-15-2010, 07:33 PM -
Inheritance
By terahawks in forum New To JavaReplies: 1Last Post: 04-23-2010, 09:58 AM -
Inheritance
By Nerijus in forum New To JavaReplies: 5Last Post: 04-20-2010, 03:47 AM -
Inheritance example
By kris4u4ever in forum New To JavaReplies: 3Last Post: 03-21-2009, 02:53 PM -
Inheritance in GUI
By Marty in forum SWT / JFaceReplies: 2Last Post: 05-11-2007, 12:54 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks