Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package figura;
- public class Figura
- {
- private static int licznik=1;
- private double pole, obwod, wymiary;
- private String nazwa;
- private int Id;
- public void Wypisz()
- {
- System.out.println(pole);
- System.out.println(wymiary);
- System.out.println(nazwa);
- System.out.println(obwod);
- }
- public Figura(double p, double o, double wymiary, String nazwa)
- {
- pole=p;
- obwod=o;
- this.wymiary=wymiary;
- this.nazwa=nazwa;
- Id=licznik;
- licznik++;
- /* System.out.println("pole "+ pole);
- System.out.println(wymiary);
- System.out.println(nazwa);
- System.out.println(obwod);*/
- }
- public Figura(double w)
- {
- wymiary=w;
- }
- public void Ustaw(double p, double o)
- {
- pole=p;
- obwod=o;
- }
- public String toString()
- {
- return Id+" "+pole+" "+obwod+" "+wymiary+" "+nazwa;
- }
- public void Ustaw(double w)
- {
- wymiary=w;
- }
- public void Ustaw(String n)
- {
- nazwa=n;
- }
- public boolean Czypunktjestwewnatrz(double x,double y)
- {
- if(x*x+y*y<=wymiary*wymiary)
- return true;
- else
- return false;
- }
- public static void main(String[] args)
- {
- Figura f1=new Figura(0,0,0,"a");
- Figura f2=new Figura(0,0,0,"a");
- f1.Ustaw(2, 3);
- //f1.Wypisz();
- System.out.println(f1);
- System.out.println(f2);
- Figura f3=new Figura(5);
- if(f3.Czypunktjestwewnatrz(12, 2)==true)
- {
- System.out.println("jest");
- }
- else
- System.out.println("nie jest");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement