Created
October 20, 2012 17:48
-
-
Save t0dd/3924185 to your computer and use it in GitHub Desktop.
Using the java.awt.Point class to set and return an (x,y) coordinate point.
This file contains 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
import java.awt.Point; | |
public class Vehicle{ | |
private Point location = new Point(); | |
private String name; | |
public Vehicle(Point location, String name){ | |
this.location = new Point(location); //Since Point object is mutable, it should be copied. | |
vehicleName = name; | |
} | |
public Point getLocation(){ | |
return new Point(this.location); //Since Point object is mutable, it should be copied. | |
} | |
} | |
//Java uses pass by value vs. pass by reference. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment