2 class Image
extends Forme
implements Compactable
{
3 final int IMAGE_MAX_SIZE
= 100;
4 Forme
[] formeCollection
;
9 formeCollection
= new Forme
[IMAGE_MAX_SIZE
];
15 formeCollection
= new Forme
[IMAGE_MAX_SIZE
];
19 private boolean isEmpty() {
20 return (formeNumber
== 0);
23 private boolean isFull() {
24 return (formeNumber
>= formeCollection
.length
);
27 public void dessiner(Piletransformations pile
) {
28 for (int i
= 0; i
< formeNumber
; i
++) {
29 formeCollection
[i
].dessiner(pile
);
33 public void deplacer(Point p
) {
34 for (int i
= 0; i
< formeNumber
; i
++) {
35 formeCollection
[i
].deplacer(p
);
39 public boolean ajouter(Forme forme
) {
40 boolean rtVal
= false;
42 formeCollection
[formeNumber
] = forme
;
49 public boolean supprimer(int index
) {
50 boolean rtVal
= false;
52 for (int j
= index
; (j
< formeNumber
- 1 && index
< formeNumber
); j
++) {
53 formeCollection
[j
] = formeCollection
[j
+ 1];
61 public void afficher() {
62 String className
= this.getClass().getSimpleName();
63 System
.out
.println("---- " + className
+ " ----");
64 for (int i
= 0; i
< formeNumber
; i
++) {
65 formeCollection
[i
].afficher();
69 public void compacter(int nElements
) {
70 int minIndex
= formeNumber
- nElements
- 1;
71 for (int i
= formeNumber
- 1; (i
> minIndex
&& !isEmpty()); i
--) {