help with extends

Discussion in 'Java' started by John Smith, Aug 31, 2008.

  1. John Smith

    John Smith Guest

    class above {

    void display() {

    class family {

    -- some functions --

    }

    class creature extends family {

    public void creature() {
    } // default constructor

    public void creatureObj(obj y) {

    -- some functions --

    } // creatureObj's constructor

    public String getName() {
    return realName;
    } // Accessor for realName

    public String getColour() {
    return realColour;
    } // Accessor for realColour

    public int getLegNumber() {
    return legNumber;
    } // Accessor for legNumber

    public int getEyeNumber() {
    return eyeNumber;
    } // Accessor for eyeNumber


    } // end class creature


    creature inputCreature = new creature();


    System.out.println("Name is " + inputCreature.getName());
    System.out.println("Colour is " + inputCreature.getColour());
    System.out.println("Leg Number is " + inputCreature.getLegNumber());
    System.out.println("Eye Number is " + inputCreature.getEyeNumber());


    } // display
    } // above



    I know I'm actually calling the default constructor which returns
    everything as null in the output such as for inputCreature.getName(). So
    the code above is wrong.

    How should I code it such that it calls the corresponding value for
    inputCreature.getName() ?
     
    John Smith, Aug 31, 2008
    #1
    1. Advertising

  2. John Smith

    John Smith Guest

    John Smith wrote:
    > public void creatureObj(obj y) {
    >
    > -- some functions --
    >
    > } // creatureObj's constructor


    oops, should be creature instead of creatureObj..

    -js
     
    John Smith, Aug 31, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon Skeet
    Replies:
    5
    Views:
    2,175
    Dale King
    Jul 8, 2003
  2. SOl

    [BEANSHELL] Extends

    SOl, Jul 19, 2003, in forum: Java
    Replies:
    0
    Views:
    397
  3. Ian Stanley

    extends multiple classes?

    Ian Stanley, Aug 9, 2003, in forum: Java
    Replies:
    13
    Views:
    155,685
    htmlrulezd00d
    Mar 13, 2012
  4. Miguel De Anda
    Replies:
    0
    Views:
    636
    Miguel De Anda
    Aug 13, 2003
  5. George Kooper
    Replies:
    3
    Views:
    2,038
    Andrew Thompson
    Jan 20, 2004
Loading...

Share This Page