Verified Commit 85c182e8 authored by Jonas Sulzer's avatar Jonas Sulzer 馃帗
Browse files

馃憣 IMPROVE: create array of 3 figures and make Figure abstract


Signed-off-by: Jonas Sulzer's avatarJonas Sulzer <jonas@violoncello.ch>
parent 6268dddf
package Ex_01;
public class FiguresGeometriques {
public static void main(String[] args) {
Figure[] figure = new Figure[3];
figure[0] = new RectangleColore(1.2, 3.4, 12.3, 43.2, 4);
figure[1] = new Cercle(2.3, 4.5, 12.2);
figure[2] = new Rectangle(1.3, 3.6, 2.3, 56.2);
for (int i = 0; i < figure.length; i++){
figure[i].affiche();
System.out.println("La surface de cette forme est :" + figure[i].surface());
}
}
}
class Figure {
abstract class Figure {
private double x; // abscisse du centre
private double y; // ordonn茅e du centre
......@@ -16,6 +26,8 @@ class Figure {
System.out.println("centre = (" + x + ", " + y + ")");
}
public abstract double surface();
public double getX() {
return x;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment