Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lektion05;
- //********************************************************************
- //Point.java Author: s144852
- //
- //Represents a point (x,y)
- //********************************************************************
- public class Point {
- int x, y;
- // Sets up point with specified data
- Point(int xIn, int yIn) {
- x = xIn;
- y = yIn;
- }
- // Returns true if the points are equal
- public boolean equals(Point p) {
- if (x == p.x && y == p.y) {
- return true;
- }
- else {
- return false;
- }
- }
- // Moves the point by dx and dy
- public void move(int dx, int dy) {
- x += dx;
- y += dy;
- }
- // Returns (x,y) in a string
- public String toString() {
- return ("(" + x + "," + y + ")");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement