Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gd;
- /**
- * Holds coordinates for an object (in this case shapes). It is quite a lot like
- * java.awt.Dimension, but with coordinates, made for this specifically.
- * @author hypesystem
- * @email [email protected]
- */
- public class Coordinate {
- private int x, y;
- /**
- * creates a coordinate object from an x and a y coordinate
- * @param x horizontal placement
- * @param y vertical placement
- */
- public Coordinate(int x, int y) {
- this.x = x;
- this.y = y;
- }
- /**
- * Moves the coordinate set.
- * @param dx amount to move horizontally
- * @param dy amount to move vertically
- */
- public void move(int dx, int dy) {
- x += dx;
- y += dy;
- }
- /**
- * Sets the position of the coordinate set to something specific.
- * @param x horizontal position
- * @param y vertical position
- */
- public void set(int x, int y) {
- this.x = x;
- this.y = y;
- }
- /**
- * Gets the horizontal position (x-coordinate)
- * @return horizontal position
- */
- public int getX() {
- return x;
- }
- /**
- * Gets the vertical position (y-coordinate)
- * @return vertical position
- */
- public int getY() {
- return y;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment