to learn java I'm working on an eco-system simulation, the source's at:
http://www.geocities.com/cjavacjava/src/
class XYZcoordinates has three fields: int x,y,z
class Cat inherits from abstract class LifeForm
each cat needs one and only one XYZcoordinates object
I think I know what I want, but keep getting errors about
static/non-static references to static/non-static variables.
please do look at the code :)
javac@mail.com
GV - 31 Mar 2004 09:41 GMT
> to learn java I'm working on an eco-system simulation, the source's at:
> http://www.geocities.com/cjavacjava/src/
[quoted text clipped - 11 lines]
>
> javac@mail.com
You need a 'cat' object first.
package staticFactoryEcoSystem;
public class Cat extends LifeForm {
public Cat() {
System.out.println("Cat default constructor..");
}//Cat
public static void main(String[] args) {
System.out.println("Cat main..");
//xyz.getX();
//this generates an error:
//create a cat object
Cat myCat = new Cat();
//get that cat's xyz reference (it's public as declared in LifeForm)
int x = myCat.xyz.getX();
System.out.println("The x coordinate = " + x);
}//main
}//Cat