Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zestaw3_4;
- public class Zestaw3_4 {
- public static void main(String[] args) {
- }
- }
- //---------------------------------------------------------------------------------------
- package zestaw3_4;
- public class Okrag {
- static int iloscOkregow = 0;
- private int Sx;
- private int Sy;
- private int promien;
- public void setSx(int Sx) {
- this.Sx = Sx;
- }
- public void setSy(int Sy) {
- this.Sy = Sy;
- }
- public void setPromien(int promien) {
- this.promien = promien;
- }
- public int getSx() {
- return Sx;
- }
- public int getSy() {
- return Sy;
- }
- public int getPromien() {
- return promien;
- }
- public void przesun(int tx, int ty) {
- Sx += tx;
- Sy += ty;
- }
- public void zmienPromien(int ileRazy) {
- promien *= ileRazy;
- }
- public void wypiszOkrag() {
- System.out.println("Sx: " + Sx + " Sy: " + Sy + " promien: " + promien);
- }
- static int ileWspolnych(Okrag o1, Okrag o2) {
- double odlegloscMiedzyOkregami = Math.sqrt(Math.pow(o1.Sx - o2.Sx, 2) + Math.pow(o1.Sy - o2.Sy, 2));
- double sumaPromieni = o1.promien + o2.promien;
- if(odlegloscMiedzyOkregami > sumaPromieni)
- return 0;
- else if(odlegloscMiedzyOkregami == sumaPromieni)
- return 1;
- else if(sumaPromieni < odlegloscMiedzyOkregami && odlegloscMiedzyOkregami < sumaPromieni)
- return 2;
- else
- return -1;
- }
- public Okrag(int Sx, int Sy, int promien) {
- this.Sx = Sx;
- this.Sy = Sy;
- this.promien = promien;
- iloscOkregow++;
- }
- public Okrag(){
- this.Sx = 0;
- this.Sy = 0;
- this.promien = 1;
- iloscOkregow++;
- }
- }
Add Comment
Please, Sign In to add comment