Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. class Point {
  2.     double x;
  3.     double y;
  4.  
  5.     Point(double x, double y) {
  6.         this.x = x;
  7.         this.y = y;
  8.     }
  9.  
  10.     double calculateDistance(Point point) {
  11.         return Math.sqrt(Math.pow(this.x - point.x, 2) + Math.pow(this.y - point.y, 2));
  12.     }
  13.  
  14.     void moveCloser(Point referencePoint, double ratio) {
  15.         this.x = this.x + (referencePoint.x - this.x) * ratio;
  16.         this.y = this.y + (referencePoint.y - this.y) * ratio;
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement