Skip to content
Snippets Groups Projects
Commit 3b02b0b7 authored by AREZKI Celia's avatar AREZKI Celia
Browse files

The ShapeContainer class now correctly adds shapes to a list with the addShape...

The ShapeContainer class now correctly adds shapes to a list with the addShape method, and the draw method iterates over the shapes to render them on the canvas.
parent be14b382
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ public class Rectangle implements Shape {
@Override
public int pointsCount() {
return 2; // Un rectangle a 2 points (deux coins opposés)
return 2;
}
@Override
......
package shape;
import javafx.scene.canvas.GraphicsContext;
import java.util.ArrayList;
import java.util.List;
......@@ -9,10 +8,13 @@ public class ShapeContainer{
private List<Shape> shapes = new ArrayList<>();
public void addShape(Shape shape){}
public void addShape(Shape shape) {
shapes.add(shape);
}
public void draw(GraphicsContext context) {
for(Shape shape : shapes)
for (Shape shape : shapes) {
shape.draw(context);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment