public void checkTPress() // this method whether T key is being pressed o not and move the object // according do following. { if (alive) // check if the ship alive { DeepSpace myDeepSpace = (DeepSpace) getWorld(); // get referance to the DeepSpace class FuelTank myFuelTank = myDeepSpace .myFuelTank(); // use myFuelTank method that return reference of FuelTank class. So // you can call method of Fueltank class. if (Greenfoot.isKeyDown("t") && !myFuelTank .empty()) // if "t" key is being pressed by user and if i have enough fuel, do // following. { move(3); // move forward direction of object setImage("rocket.png"); // set the image rocket that seems like burning fuel. myFuelTank .burn(); // call the Fueltank class method in order to decrese level of fuel on screen } else setImage("rocket_noThrust.png"); // if no key is being press than set the regular picture. } }