3 author
= "Jérôme Benoit",
6 class Piletransformations
{
7 private Point
[] transformations
;
8 private int currentTransformation
;
10 Piletransformations(int size
) {
11 transformations
= new Point
[size
];
12 for (int i
= 0; i
< transformations
.length
; i
++) {
13 transformations
[i
] = new Point(0, 0);
15 currentTransformation
= 0;
18 public Point
getCurrentTransformation() {
20 return transformations
[currentTransformation
];
22 return transformations
[currentTransformation
- 1];
26 private boolean isEmpty() {
27 return (currentTransformation
== 0);
30 private boolean isFull() {
31 return (currentTransformation
>= transformations
.length
);
34 public boolean empiler(Point p
) {
35 boolean rtVal
= false;
37 transformations
[currentTransformation
] = p
;
38 currentTransformation
++;
40 } else if (!isFull()) {
41 transformations
[currentTransformation
] = transformations
[currentTransformation
- 1].additionner(p
);
42 currentTransformation
++;
48 public Point
depiler() {
50 currentTransformation
--;
51 return transformations
[currentTransformation
];
53 return transformations
[currentTransformation
];
57 public void display() {
58 System
.out
.println("----");
59 for (int i
= 0; i
< currentTransformation
; i
++) {
60 System
.out
.println(transformations
[i
].toString());