Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package punkt;
  7.  
  8. public class Punkt {
  9.  
  10. int x;
  11. int y;
  12. byte kolor = 0;
  13.  
  14. int getX() {
  15. return x;
  16. }
  17.  
  18. int getY() {
  19. return y;
  20. }
  21.  
  22. byte getKolor() {
  23. return kolor;
  24. }
  25.  
  26. void setX(int _x) {
  27. x = _x;
  28. }
  29.  
  30. void przesunPunkt(int nowyX, int nowyY) {
  31. x = nowyX;
  32. y = nowyY;
  33. }
  34.  
  35. void zmienKolor(byte nowyKolor) {
  36. kolor = nowyKolor;
  37. }
  38.  
  39. boolean isKolor(byte color) {
  40. if (kolor == color) {
  41. return true;
  42. } else {
  43. return false;
  44. }
  45. }
  46.  
  47. public static void main(String[] args) {
  48. Punkt p1 = new Punkt();
  49. p1.przesunPunkt(1, 2);
  50. Punkt p2 = new Punkt();
  51. byte kolor = p2.getKolor();
  52. System.out.println("Wspólrzędne pierwszego punktu wynoszą ["
  53. + p1.getX() + "," + p1.getY() + "] kolor drugiego punktu: " + kolor);
  54. Punkt p3 = new Punkt();
  55. p3.przesunPunkt(2,4);
  56. byte kolor3 = p3.getKolor();
  57. p3.zmienKolor((byte)5);
  58. boolean a = p3.isKolor(kolor3);
  59. System.out.println("kolor 3 to" + kolor3 +", Czy jest kolorem?"+ a);
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement