Created
April 16, 2015 19:44
-
-
Save jonathan-irvin/edaf8cc413a3befa2880 to your computer and use it in GitHub Desktop.
Vector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Vector { | |
private double x; | |
private double y; | |
public Vector (double x, double y){ | |
this.x = x; | |
this.y = y; | |
} | |
public double getX () { | |
return x; | |
} | |
public double getY () { | |
return y; | |
} | |
public void setX (double newX) { | |
x = newX; | |
} | |
public void setY (double newY) { | |
y = newY; | |
} | |
public double getLength() { | |
double length = Math.sqrt(x*x + y*y); | |
return length; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment