01: //Plik: 03_DziedziczKonstr/Point.java
02:
03: public class Point {
04:
05: private int x, y;
06:
07: public Point(int x, int y) {
08: this.x = x;
09: this.y = y;
10: }
11:
12: public Point(int x) {
13: this(x,0);
14: }
15:
16: public Point() {
17: this(0,0);
18: }
19:
20: public Point translate(int dx,int dy) {
21: x += dx;
22: y += dy;
23: return this;
24: }
25:
26: public Point scale(int sx,int sy) {
27: x *= sx;
28: y *= sy;
29: return this;
30: }
31:
32: public int getX() {
33: return x;
34: }
35:
36: public int getY() {
37: return y;
38: }
39:
40: @Override
41: public String toString() {
42: return "[" + x + "," + y + "]";
43: }
44: }