Guest User

Untitled

a guest
Dec 22nd, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. // Punkt.java
  2.  
  3. //! import javax.swing.*;   // Zbędne.
  4.  
  5. // Nie używamy polskich znaków w nazwach, gdyż mogą pojawić się
  6. // problemy z czymkolwiek.
  7.  
  8. public class Punkt{
  9. //!    protected double x;  // Nie używamy protected, chyba że naprawdę jest
  10. //!    protected double y;  // potrzebne (przy dziedziczeniu klas).
  11.     private double x;
  12.     private double y;
  13.  
  14. //!    public Punkt(x,y){  // Brakuje typów parametrów
  15.     public Punkt(double x, double y) {
  16. //!        this.x  = p.x;   // Skąd to p?
  17. //!        this.y = p.y;
  18.         this.x = x;
  19.         this.y = y;
  20.     }
  21.     public Punkt przesuniecie(double a, double b) {
  22.         this.x += a;
  23.         this.y += b;
  24.         return this;
  25.     }
  26.     public String toString() {
  27. //!        return "(" + x + ", " + ")";
  28.         return "(" + x + ", " + y + ")";
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment