dimanche 22 février 2015

How to access a local variable globally (Java)



How can I call the variables in public void angles() to public void draw(Pen p)?


I'm also aware that there might be other flaws in my program since this is still a new concept to me, so any other pointers are greatly appreciated (This is only a part of the program).


Code if needed:



public void angles(){
double a;
double b;
double c;
double angle1;
double angle2;
double angle3;

side a = length(xPos, yPos, x2, y2);
side b = length(x2, y2, x3, y3);
side c = length(xPos, yPos, x3, y3);

angle1 = Math.asin(double ((-((a^2)/(2bc)))+((b)/(2c))+((c)/(2b))));
angle2 = Math.asin(double ((-((b^2)/(2ac)))+((a)/(2c))+((c)/(2a))));
angle3 = Math.asin(double ((-((c^2)/(2ab)))+((a)/(2b))+((b)/(2a))));

}

public void draw (Pen p){
p.up();
p.move(xPos, yPos);
p.down();
p.turn(angle1); pen.move(a);
p.turn(angle2); pen.move(b);
p.turn(angle3); pen.move(c);
}



Aucun commentaire:

Enregistrer un commentaire