Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package punkt;
- public class Punkt {
- private final double x,y;
- public Punkt(double x, double y) {
- this.x=x;
- this.y=y;
- }
- public double getX() {
- return x;
- }
- public double getY() {
- return y;
- }
- @Override
- public boolean equals(Object obj) {
- if(obj instanceof Punkt)
- {
- Punkt other = (Punkt)obj;
- return (x == other.x && y == other.y);
- }
- return false;
- }
- @Override
- public int hashCode() {
- return super.hashCode();
- }
- @Override
- public String toString() {
- return "Instancja klasy Punkt zawierająca wpolrzedne( "+x+","+y+")";
- }
- /**
- * Początek układu współrzędnych.
- * W tym miejscu słowo kluczowe final oznacza, że statyczne
- * pole klasy Punkt nie może zostać zmienione.
- * Dotyczy to jednak samej referencji, a nie obiektu, na który
- * wskazuje.
- */
- public static final Punkt O = new Punkt(0, 0);
- /**
- * Punkt (1,0) w układzie współrzędnych
- */
- public static final Punkt E_X = new Punkt(1, 0);
- /**
- * Punkt (0,1) w układzie współrzędnych
- */
- public static final Punkt E_Y = new Punkt(0, 1);
- }
Add Comment
Please, Sign In to add comment