Results 1 to 2 of 2
  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default 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.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default Re: using inheritance

    Quote Originally Posted by droidus View Post
    do not understand why you would want to create an extra file for doing something else... why not just import it?
    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.

    what I would put in my interface class
    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.

Similar Threads

  1. using inheritance
    By senca in forum New To Java
    Replies: 4
    Last Post: 08-15-2010, 07:33 PM
  2. Inheritance
    By terahawks in forum New To Java
    Replies: 1
    Last Post: 04-23-2010, 09:58 AM
  3. Inheritance
    By Nerijus in forum New To Java
    Replies: 5
    Last Post: 04-20-2010, 03:47 AM
  4. Inheritance example
    By kris4u4ever in forum New To Java
    Replies: 3
    Last Post: 03-21-2009, 02:53 PM
  5. Inheritance in GUI
    By Marty in forum SWT / JFace
    Replies: 2
    Last Post: 05-11-2007, 12:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •