Advertisement
alicemiriel

Untitled

Mar 7th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. package pl.sda.obiektowosc.pl.sda.obiektowosc.ukladkartezjanski;
  2.  
  3. public class Punkt {
  4.     private int x;
  5.     private int y;
  6.     double odleglosc;
  7.  
  8.     public Punkt(int x, int y) {
  9.         this.x = x;
  10.         this.y = y;
  11.  
  12.     }
  13.  
  14.     public double obliczOdleglosc(Punkt pierwszy, Punkt drugi) {
  15.         int x = Math.abs(pierwszy.x - drugi.x);
  16.         int y = Math.abs(pierwszy.y - drugi.y);
  17.         this.odleglosc = Math.sqrt(Math.pow(x, y));
  18.         return odleglosc;
  19.     }
  20.  
  21.     private void wyswietl(int x, int y) {
  22.         System.out.println("Twoj punkt ma wspolrzedne: " + " wartosc x " + x + " oraz wartosc y:" + y);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement