SHARE
TWEET

Udemy_32_Point

Flaron Sep 19th, 2019 176 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. public class Point {
  4.     private int x;
  5.     private int y;
  6.  
  7.     public Point() {
  8.     }
  9.  
  10.     public int getX() {
  11.         return x;
  12.     }
  13.  
  14.     public void setX(int x) {
  15.         this.x = x;
  16.     }
  17.  
  18.     public int getY() {
  19.         return y;
  20.     }
  21.  
  22.     public void setY(int y) {
  23.         this.y = y;
  24.     }
  25.  
  26.     public Point(int x, int y) {
  27.         this.x=x;
  28.         this.y=y;
  29.     }
  30.  
  31.     public double distance() {
  32.         return Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
  33.     }
  34.  
  35.     public double distance(int x, int y) {
  36.  
  37.         return  Math.sqrt(Math.pow(x-this.x, 2) + Math.pow(y-this.y, 2));
  38.     }
  39.  
  40.     public double distance(Point p) {
  41.         return distance(p.x, p.y);
  42.     }
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top