How to return class - type in a method

Viewed 41778

I have a class

public class Engine {

    Double engineSize;
    public Engine(){
        this.engineSize = 1.0;
    }
    public Double getEngineSize() {

        return engineSize;
    }
}

I have another class:

public class ModelT {

    public Engine getEngine() {

        return null;
    }}

Now I want to pass this test:

@Test

public void shouldHaveTheCorrectEngineSize(){
    assertThat(modelT.getEngine().getEngineSize(), is(1.0));
}

I have the difficulty how can I return the Engine type in a method, I tried several ways but knowledge is limited because I am beginner to java.. Could you please tell me how could i do this? and what is the name of concept that i could further read on..

5 Answers
Related