So I have a subclass that inherits from another class. I want to create an object of the subclass Test and have its properties carry over to another class called Engine (explained below).
package comulap;
public class Test extends Comulap {
public String fudge = "fudge";
public static void main(String[] args){
Test c = new Test();
}
}
This is the superclass Comulap
package comulap;
import comulap.core.Engine;
public class Comulap {
public String fudge;
Engine engine;
public Comulap(){
engine=new Engine(this);
}
}
And this is the engine class which I want to use the Test methods and attributes:
package comulap.core;
import comulap.Comulap;
public class Engine {
Comulap comulap;
public Engine(Comulap c){
comulap=c;
System.out.println(comulap.fudge);
}
}
However, when I run this, the engine object thinks fudge is null as if just a regular Comulapobject is being passed, not a Test class. How do I pass the Test class through in the regular Comulap class constructor not just a standard Comulap class?