Skip to content
Snippets Groups Projects
Commit f526be30 authored by MANSOUR Chadi's avatar MANSOUR Chadi
Browse files

started filling the classes and correcting some mistakes

parent d7744a7b
Branches
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ import javafx.scene.canvas.GraphicsContext;
import java.util.List;
public class AbstractShape implements Shape {
List<Point2D> points;
private List<Point2D> points;
public AbstractShape(List<Point2D> points) {
this.points = points;
......@@ -17,16 +17,23 @@ public class AbstractShape implements Shape {
}
@Override
public int pointsCount() {
return 0;
int count = 0;
for (Point2D point : points) {
count++;
}
return count;
}
@Override
public Point2D point(int index) {
return null;
return index < points.size() ? points.get(index) : null;
}
@Override
public void draw(GraphicsContext context) {
for (Point2D point : points) {
}
}
}
......@@ -4,13 +4,13 @@ import javafx.scene.canvas.GraphicsContext;
public class BorderDecorator extends Decorator {
double radius;
private double radius;
public BorderDecorator(Shape decoratedShape ,double radius) {
super(decoratedShape);
this.radius = radius;
}
public void drawDecoration(GraphicsContext context) {
protected void drawDecoration(GraphicsContext context) {
}
}
......@@ -3,12 +3,12 @@ package shape;
import javafx.scene.canvas.GraphicsContext;
public class CenterDecorator extends Decorator{
double radius;
private double radius;
public CenterDecorator(Shape decoratedShape, double radius) {
super(decoratedShape);
this.radius = radius;
}
public void drawDecoration(GraphicsContext context) {
protected void drawDecoration(GraphicsContext context) {
}
}
......@@ -3,14 +3,14 @@ package shape;
import javafx.geometry.Point2D;
import javafx.scene.canvas.GraphicsContext;
public class Decorator implements Shape {
private Shape shape;
public abstract class Decorator implements Shape {
protected Shape decoratedshape;
public Decorator(Shape decoratedShape) {
this.shape = decoratedShape;
this.decoratedshape = decoratedShape;
}
@Override
public int pointsCount() {
return 0;
return decoratedshape.pointsCount();
}
@Override
......@@ -22,7 +22,7 @@ public class Decorator implements Shape {
public void draw(GraphicsContext context) {
}
public void drawDecoration(GraphicsContext context) {
protected void drawDecoration(GraphicsContext context) {
}
}
......@@ -6,7 +6,7 @@ import javafx.scene.paint.Color;
public class Polygon implements Shape {
Color color;
private Color color;
public Polygon(Color color, Point2D... points) {
this.color = color;
......@@ -19,11 +19,12 @@ public class Polygon implements Shape {
@Override
public Point2D point(int index) {
return null;
return point(index);
}
@Override
public void draw(GraphicsContext context) {
context.setFill(color);
}
}
......@@ -5,23 +5,23 @@ import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class Rectangle implements Shape{
Color color;
private Color color;
Rectangle(Color color, Point2D point0, Point2D point1){
this.color = color;
}
@Override
public int pointsCount() {
return 0;
return 2;
}
@Override
public Point2D point(int index) {
return null;
return point(index);
}
@Override
public void draw(GraphicsContext context) {
context.setFill(color);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment