-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.java
More file actions
48 lines (40 loc) · 752 Bytes
/
Point.java
File metadata and controls
48 lines (40 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
public class Point {
public int x;
public int y;
// un constructeur
public Point (){
this.x = 0 ;
this.y = 0 ;
}
public Point ( int x , int y ) {
this.x = x ;
this.y = y ;
}
public int getX(){
return x;
}
public int getY(){
return y;
}
public void setX(int X){
this.x = x;
}
public void setY(int y){
this.y = y;
}
public void move(int dx, int dy){
this.x = this.x + dx;
this.y = this.y + dy;
}
public static void main(String[] args) {
Point p = new Point(10,15);
System.out.println(p.x + " " + p.y);
Point Pa = new Point();
System.out.println(Pa.x + " " + Pa.y);
p.setX(12);
p.setY(18);
System.out.println(p.x + " " + p.y);
Pa.move(10, 10);
System.out.println(Pa.x + " " + Pa.y);
}
}