2 class Piletransformations
{
3 private Point
[] transformations
;
4 private int currentTransformation
;
6 Piletransformations(int size
) {
7 transformations
= new Point
[size
];
8 for (int i
= 0; i
< transformations
.length
; i
++) {
9 transformations
[i
] = new Point(0, 0);
11 currentTransformation
= 0;
14 public Point
getCurrentTransformation() {
16 return transformations
[currentTransformation
];
18 return transformations
[currentTransformation
- 1];
22 private boolean isEmpty() {
23 return (currentTransformation
== 0);
26 private boolean isFull() {
27 return (currentTransformation
>= transformations
.length
);
30 public boolean empiler(Point p
) {
31 boolean rtVal
= false;
33 transformations
[currentTransformation
] = p
;
34 currentTransformation
++;
36 } else if (!isFull()) {
37 transformations
[currentTransformation
] = transformations
[currentTransformation
- 1].additionner(p
);
38 currentTransformation
++;
44 public Point
depiler() {
46 currentTransformation
--;
47 return transformations
[currentTransformation
];
49 return transformations
[currentTransformation
];
53 public void display() {
54 System
.out
.println("----");
55 for (int i
= 0; i
< transformations
.length
; i
++) {
56 System
.out
.println(transformations
[i
].toString());