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

Ivan Meredith
  • 2,222
  • 14
  • 13

1 Answers1

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.

jlordo
  • 37,490
  • 6
  • 58
  • 83
  • 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 '12 at 23:10