Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. package figura;
  2. public class Figura
  3. {
  4. private static int licznik=1;
  5. private double pole, obwod, wymiary;
  6. private String nazwa;
  7. private int Id;
  8. public void Wypisz()
  9. {
  10. System.out.println(pole);
  11. System.out.println(wymiary);
  12. System.out.println(nazwa);
  13. System.out.println(obwod);
  14. }
  15. public Figura(double p, double o, double wymiary, String nazwa)
  16. {
  17. pole=p;
  18. obwod=o;
  19. this.wymiary=wymiary;
  20. this.nazwa=nazwa;
  21. Id=licznik;
  22. licznik++;
  23. /* System.out.println("pole "+ pole);
  24. System.out.println(wymiary);
  25. System.out.println(nazwa);
  26. System.out.println(obwod);*/
  27. }
  28. public Figura(double w)
  29. {
  30. wymiary=w;
  31. }
  32. public void Ustaw(double p, double o)
  33. {
  34. pole=p;
  35. obwod=o;
  36. }
  37. public String toString()
  38. {
  39. return Id+" "+pole+" "+obwod+" "+wymiary+" "+nazwa;
  40. }
  41. public void Ustaw(double w)
  42. {
  43. wymiary=w;
  44. }
  45. public void Ustaw(String n)
  46. {
  47. nazwa=n;
  48. }
  49. public boolean Czypunktjestwewnatrz(double x,double y)
  50. {
  51. if(x*x+y*y<=wymiary*wymiary)
  52. return true;
  53. else
  54. return false;
  55. }
  56. public static void main(String[] args)
  57. {
  58. Figura f1=new Figura(0,0,0,"a");
  59. Figura f2=new Figura(0,0,0,"a");
  60. f1.Ustaw(2, 3);
  61. //f1.Wypisz();
  62. System.out.println(f1);
  63. System.out.println(f2);
  64. Figura f3=new Figura(5);
  65. if(f3.Czypunktjestwewnatrz(12, 2)==true)
  66. {
  67. System.out.println("jest");
  68. }
  69. else
  70. System.out.println("nie jest");
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement