0

I have two classes. One class has a variable "Image plane = null;" in this class (Class1) I call a function move.lookright() which executes a function on another class file called move.java, My issue is I need to import a few variables into this class so that I can use them and make the Image move right when the function is called.

void lookRight() {
    if(plane.getRotation() < 0 ){       
        if(plane.getRotation()>-270 ){
            plane.rotate(-0.2f * delta);
        }
        if(plane.getRotation()<1){
            plane.rotate(0.2f * delta);
        }
    }
}

This class needs the variables delta and plane.

Any help is appreciated. And yes I did google this answer many times but was unable to find a answer.

Thanks, Kyle

1 Answer 1

4

Change the method signature to

void lookRight(DataTypeOfPlane plane, double delta)
// replace DataTypeOfPlane with the actual data type of the variable plane ;)

and pass the parameters when calling the method.

1
  • This is an excellent solution. Alternatively, you could provide a DataTypeOfPlane object to the Move object on instantiation and use some getters. Same principle, different access method.
    – corsiKa
    Nov 29, 2012 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.