-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarre.java
More file actions
84 lines (64 loc) · 1.85 KB
/
Carre.java
File metadata and controls
84 lines (64 loc) · 1.85 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package main.java.com.example;
public class Carre {
private int Cote;
private Point Centre;
public Carre(int Abscisse,int Ordonnée,int Cote){
this(Abscisse,Ordonnée);
this.Cote=Cote;
}
public Carre(int Abscisse,int Ordonnée){
this.Centre = new Point(Abscisse,Ordonnée);
}
public int getCote() {
return this.Cote;
}
public void setCote(int Cote) {
this.Cote = Cote;
}
public Point getCentre() {
return this.Centre;
}
public void setCentre(Point Centre) {
this.Centre = Centre;
}
@Override
public String toString() {
return "{" +
" Cote='" + getCote() + "'" +
", Centre='" + getCentre() + "'" +
"}";
}
public void TranslCarreHoriz(int a){
this.Centre.TranslHoriz(a);
}
public void TranslCarreVert (int a){
this.Centre.TranslVert(a);
}
public void TranslationCarre (int a, int b){
this.Centre.Translation(a,b);
}
public void TranslationCarre (int a){
this.Centre.Translation(a);
}
public boolean equals (Carre C){
return this.getCote() == C.getCote() && this.Coincide(C);
}
public int Surface(){
return this.getCote()*this.getCote();
};
public int perimetre(){
return this.getCote()*4;
};
public double diagonale(){
return Math.sqrt(this.getCote()*this.getCote() * 2);
};
public Point[] CoinsDuCarre(){
Point points[] = new Point[4];
points[0] = new Point(this.getCentre().getAbscisse() + this.getCote() / 2, this.getCentre().getOrdonnée() + this.getCote() / 2);
points[1] = new Point(this.getCentre().getAbscisse() + this.getCote() / 2, this.getCentre().getOrdonnée() - this.getCote() / 2);
points[2] = new Point(this.getCentre().getAbscisse() - this.getCote() / 2, this.getCentre().getOrdonnée() + this.getCote() / 2);
points[3] = new Point(this.getCentre().getAbscisse() - this.getCote() / 2, this.getCentre().getOrdonnée() - this.getCote() / 2 );
return points;
}
;
}