Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package punkt;
- public class Punkt {
- int x;
- int y;
- byte kolor = 0;
- int getX() {
- return x;
- }
- int getY() {
- return y;
- }
- byte getKolor() {
- return kolor;
- }
- void setX(int _x) {
- x = _x;
- }
- void przesunPunkt(int nowyX, int nowyY) {
- x = nowyX;
- y = nowyY;
- }
- void zmienKolor(byte nowyKolor) {
- kolor = nowyKolor;
- }
- boolean isKolor(byte color) {
- if (kolor == color) {
- return true;
- } else {
- return false;
- }
- }
- public static void main(String[] args) {
- Punkt p1 = new Punkt();
- p1.przesunPunkt(1, 2);
- Punkt p2 = new Punkt();
- byte kolor = p2.getKolor();
- System.out.println("Wspólrzędne pierwszego punktu wynoszą ["
- + p1.getX() + "," + p1.getY() + "] kolor drugiego punktu: " + kolor);
- Punkt p3 = new Punkt();
- p3.przesunPunkt(2,4);
- byte kolor3 = p3.getKolor();
- p3.zmienKolor((byte)5);
- boolean a = p3.isKolor(kolor3);
- System.out.println("kolor 3 to" + kolor3 +", Czy jest kolorem?"+ a);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement