blackpab

Java Zestaw 3 - Zadanie 4

Mar 13th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1. package zestaw3_4;
  2.  
  3. public class Zestaw3_4 {
  4.    
  5.     public static void main(String[] args) {        
  6.     }    
  7. }
  8.  
  9. //---------------------------------------------------------------------------------------
  10.  
  11. package zestaw3_4;
  12.  
  13. public class Okrag {
  14.     static int iloscOkregow = 0;
  15.     private int Sx;
  16.     private int Sy;
  17.     private int promien;
  18.    
  19.     public void setSx(int Sx) {
  20.         this.Sx = Sx;
  21.     }
  22.  
  23.     public void setSy(int Sy) {
  24.         this.Sy = Sy;
  25.     }
  26.  
  27.     public void setPromien(int promien) {
  28.         this.promien = promien;
  29.     }
  30.  
  31.     public int getSx() {
  32.         return Sx;
  33.     }
  34.  
  35.     public int getSy() {
  36.         return Sy;
  37.     }
  38.  
  39.     public int getPromien() {
  40.         return promien;
  41.     }
  42.    
  43.     public void przesun(int tx, int ty) {
  44.         Sx += tx;
  45.         Sy += ty;
  46.     }
  47.    
  48.     public void zmienPromien(int ileRazy) {
  49.         promien *= ileRazy;
  50.     }
  51.    
  52.     public void wypiszOkrag() {
  53.         System.out.println("Sx: " + Sx + " Sy: " + Sy + " promien: " + promien);
  54.     }
  55.    
  56.     static int ileWspolnych(Okrag o1, Okrag o2) {
  57.         double odlegloscMiedzyOkregami = Math.sqrt(Math.pow(o1.Sx - o2.Sx, 2) + Math.pow(o1.Sy - o2.Sy, 2));
  58.         double sumaPromieni = o1.promien + o2.promien;
  59.        
  60.         if(odlegloscMiedzyOkregami > sumaPromieni)
  61.             return 0;
  62.         else if(odlegloscMiedzyOkregami == sumaPromieni)
  63.             return 1;
  64.         else if(sumaPromieni < odlegloscMiedzyOkregami && odlegloscMiedzyOkregami < sumaPromieni)
  65.             return 2;
  66.         else
  67.             return -1;        
  68.     }
  69.    
  70.     public Okrag(int Sx, int Sy, int promien) {
  71.         this.Sx = Sx;
  72.         this.Sy = Sy;
  73.         this.promien = promien;
  74.         iloscOkregow++;
  75.     }
  76.    
  77.     public Okrag(){
  78.         this.Sx = 0;
  79.         this.Sy = 0;
  80.         this.promien = 1;
  81.         iloscOkregow++;
  82.     }
  83. }
Add Comment
Please, Sign In to add comment