public class Circle {
private Point2D center;
private double radius;
private double area;
public Circle(Point2D center, double radius) {
}
public Circle(double radius) {
}
public double getArea() {
}
public Point2D getCenter() {
}
public void setCenter(Point2D p) {
}
public double getRadius() {
}
public void setRadius(double radius) {
}
public Circle clone() {
}
public String toString() {
}
public boolean equals(Circle c) {
}
private void updateArea() {
}
}
public class Hanoi {
// Algorithme des tours de Hanoi
public static void moveShapes(ShapeStack fromTower, ShapeStack toTower, ShapeStack viaTower,
int nbShapes) {
if (nbShapes > 0) {
moveShapes(fromTower, viaTower, toTower, nbShapes - 1);
toTower.push(fromTower.top());
fromTower.pop();
moveShapes(viaTower, toTower, fromTower, nbShapes - 1);
}
}
public static void main(String[] args) {
int n = 2;
// Creation des trois tours de formes
ShapeStack tower0 = new ShapeStackFixedSizeArray(n * 2);
ShapeStack tower1 = new ShapeStackFixedSizeArray(n * 2);
ShapeStack tower2 = new ShapeStackFixedSizeArray(n * 2);
// La première tour est remplie de formes d'aires croissantes
for (int r = 1; r <= n; ++r) {
Circle c = new Circle(r);
tower0.push(c);
Rectangle sq = new Rectangle(new Point2DCartesien(0, 0),new Point2DCartesien(r, r));
tower0.push(sq);
}
// Affichage des trois tours avant les deplacements
System.out.println("Avant les deplacements");
System.out.println("Tour 1: ");
System.out.println(tower0);
System.out.println("Tour 2: ");
System.out.println(tower1);
System.out.println("Tour 3: ");
System.out.println(tower2);
// Deplacement des formes de la 1ere tour vers la 3ieme
Hanoi.moveShapes(tower0, tower2, tower1, n * 2);
// Affichage des trois tours apres les deplacements
System.out.println("Apres les deplacements");
System.out.println("Tour 1: ");
System.out.println(tower0);
System.out.println("Tour 2: ");
System.out.println(tower1);
System.out.println("Tour 3: ");
System.out.println(tower2);
}
}