Advertisement
CorpusCorpus

point

Jun 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public class Point {
  2.  
  3. private double x;
  4. private double y;
  5.  
  6. public Point() {
  7. this.x = 0;
  8. this.y = 0;
  9. }
  10.  
  11. Point(double x, double y) {
  12. this.x = x;
  13. this.y = y;
  14. }
  15.  
  16. public void print() {
  17. System.out.println("Point(x: " + x + " y: " + y + ")");
  18. }
  19.  
  20. public void set(double x, double y) {
  21. this.x = x;
  22. this.y = y;
  23. }
  24.  
  25. public double length(Point p) {
  26. return Math.pow(Math.abs(this.x - p.x), 2) + Math.pow(Math.abs(this.y - p.y), 2);
  27. }
  28.  
  29. public void move(double a, double b) {
  30. this.x += a;
  31. this.y += b;
  32. }
  33.  
  34. public boolean equalsPoint(Point p) {
  35. return (this.x == p.x) && (this.y == p.y);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement