help with extends



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() ?
.



Relevant Pages

  • Re: Problem using anonymous inner class, KeyAdapter()
    ... >> public void MainGame(){ ... >>No errors at all were thrown up at compile time or at run time, ... > In the case of the constructor. ... > well suited to a linear presentation medium. ...
    (comp.lang.java.gui)
  • Re: Use the accessor! Was: Copy Constructor Usage
    ... I think you are getting too hung up on the copy constructor bit. ... accessor fns on some bogus efficiency argument. ... a field 'leng' might map onto an accessor 'size'; ... No style or design rules give us a free lunch. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Setting the Focus on Java windows (JInternalFrames)
    ... RedGrittyBrick wrote: ... It is interesting that you pass desktop to the constructor so that the constructor adds the new frame to the desktop, yet you have the calling method do the work of adding the frame to a list. ... Listfoos = ... ... public void actionPerformed{ ...
    (comp.lang.java.programmer)
  • Re: converting code into a bean
    ... Bean-aware tools do not recompile your beans, ... controller to change the model, with the result then reflected by the ... > public void setInit{ ... > them to the model constructor when compiling - this is not working, ...
    (comp.lang.java.programmer)
  • Re: copy contructor
    ... inheritance in Perl) it *has* an accessor. ... One of the tenets about Perl inheritance is "If you ... Sure it can have its own constructor. ... provided you call the base class' ...
    (comp.lang.perl.misc)