public class Location
extends java.lang.Object
implements java.lang.Cloneable
| Constructor and Description |
|---|
Location(double xInitial,
double yInitial)
Construct a Location with specified coordinates.
|
| Modifier and Type | Method and Description |
|---|---|
Location |
clone()
Generate a copy of this Location.
|
static double |
distance(Location p1,
Location p2)
Compute the distance between two Locations.
|
boolean |
equals(java.lang.Object obj)
Compare this Location to another object for equality.
|
double |
getX()
Get the x coordinate of this Location.
|
double |
getY()
Get the y coordinate of this Location.
|
static Location |
midpoint(Location p1,
Location p2)
Generate and return a Location halfway between two others.
|
void |
rotate90()
Rotate this Location 90 degrees in a clockwise direction.
|
void |
shift(double xAmount,
double yAmount)
Move this Location by given amounts along the x and y axes.
|
java.lang.String |
toString()
Generate a String representation of this Location.
|
public Location(double xInitial,
double yInitial)
xInitial - the initial x coordinate of this LocationyInitial - the initial y coordinate of this Locationpublic Location clone()
clone in class java.lang.Objectpublic static double distance(Location p1, Location p2)
p1 - the first Locationp2 - the second Locationpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - an object with which this Location will be comparedpublic double getX()
public double getY()
public static Location midpoint(Location p1, Location p2)
p1 - the first Locationp2 - the second Locationpublic void rotate90()
public void shift(double xAmount,
double yAmount)
xAmount - the amount to move this Location along the x axisyAmount - the amount to move this Location along the y axispublic java.lang.String toString()
toString in class java.lang.Object