Commit | Line | Data |
---|---|---|
c05c2289 JB |
1 | |
2 | class Point { | |
3 | private double x; | |
4 | private double y; | |
5 | ||
6 | Point() { | |
7 | /* | |
8 | * FIXME?: init to (0,0) | |
9 | */ | |
10 | } | |
11 | ||
12 | Point (double x, double y) { | |
13 | this.x = x; | |
14 | this.y = y; | |
15 | } | |
16 | ||
17 | public void setX(double x) { | |
18 | this.x = x; | |
19 | } | |
20 | ||
21 | public double getX() { | |
22 | return x; | |
23 | } | |
24 | ||
25 | public void setY(double y) { | |
26 | this.y = y; | |
27 | } | |
28 | ||
29 | public double getY() { | |
30 | return y; | |
31 | } | |
32 | ||
33 | public Point additionner(Point p) { | |
34 | Point pNew = new Point(p.getX() + getX(), p.getY() + getY()); | |
35 | return pNew; | |
36 | } | |
37 | ||
38 | public String toString() { | |
39 | return "(" + x + "," + y + ")"; | |
40 | } | |
41 | ||
42 | } |