Advertisement
alvsjo

tacka (15-02-17)

Feb 22nd, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1.  
  2. public class Tacka {
  3.  
  4.     private double x,y;
  5.     private String ime;
  6.  
  7.        
  8.     public Tacka(double x, double y, String ime) {
  9.         this.x = x;
  10.         this.y = y;
  11.         this.ime = ime;
  12.     }
  13.    
  14.     public Tacka(Tacka t)
  15.     {
  16.         //this.x=t.x;
  17.         this.setX(t.x);
  18.         y=t.y;
  19.         //ime=t.ime;
  20.         ime = new String(t.ime);
  21.     }
  22.    
  23.  
  24.  
  25.     public double getX() {
  26.         return x;
  27.     }
  28.  
  29.     public void setX(double x) {
  30.         this.x = x;
  31.     }
  32.  
  33.     public double getY() {
  34.         return y;
  35.     }
  36.  
  37.     public void setY(double y) {
  38.         this.y = y;
  39.     }
  40.  
  41.     public String getIme() {
  42.         return ime;
  43.     }
  44.  
  45.     public void setIme(String ime) {
  46.         this.ime = ime;
  47.     }
  48.  
  49.     public void stampa(boolean newLine)
  50.     {
  51.        
  52.         System.out.print(ime+" ("+x+", "+y+")");
  53.         if (newLine)
  54.         {
  55.             System.out.println();
  56.         }
  57.     }
  58.    
  59.    
  60.     @Override
  61.     public String toString() {
  62.         // TODO Auto-generated method stub
  63.         return ime+" ("+x+", "+y+")";
  64.        
  65.     }
  66.  
  67.     public double dist(Tacka t1)
  68.     {
  69.         double dx=x-t1.x;
  70.         double dy=y-t1.y;
  71.         return Math.sqrt((dx*dx)+(dy*dy));
  72.     }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement