-
Notifications
You must be signed in to change notification settings - Fork 0
/
Figure.java
63 lines (44 loc) · 1.3 KB
/
Figure.java
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
package logicieldedessin;
import java.awt.Color;
import java.awt.Graphics;
import java.io.Serializable;
import java.util.LinkedList;
/**
* @author freshloic
*
*/
abstract class Figure implements Cloneable,Serializable, Comparable<Object>{
private static final long serialVersionUID = 3516062312457681922L;
private String nom;
private Color couleur;
public abstract void afficher();
public abstract void translater(double dx, double dy);
public abstract Point getCentre();
abstract Object cloner();
public abstract void paint(Graphics gc);
public abstract LinkedList<Point> getPoints();
public String getNom() {
return nom.toUpperCase();
}
public void setNom(String nom) {
if(nom != null) this.nom = nom;
}
public LinkedList<Point> creatList(LinkedList<Figure> l){
LinkedList<Point> lp = new LinkedList<Point>();
for( Figure f : l){ lp.addAll(((Point) f).getPoints());}
return lp;
}
public int NbFigure(LinkedList<Figure> figures, Figure f){
int nbf = 0;
for( Figure e : figures) if(e.getClass().equals(f.getClass())) nbf++;
return nbf;
}
public int compareTo(Figure f2){ return this.getPoids() - f2.getPoids();}
abstract int getPoids();
public void setCouleur(Color couleur) {
if(couleur != null) this.couleur = couleur;
}
public Color getCouleur() {
return couleur;
}
}