Skip to content
Snippets Groups Projects
Select Git revision
  • 047d15d62a22840d4455d77bc936c6bc1764cdfe
  • main default protected
  • correction_video
  • going_further
  • ImprovedMouseInteraction
  • final2023
  • template
  • ModifGUI
8 results

Main.java

Blame
  • Forked from YAGOUBI Rim / Game of life Template
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Circle.java 945 B
    package shape;
    
    import javafx.geometry.Point2D;
    import javafx.scene.canvas.GraphicsContext;
    import javafx.scene.paint.Color;
    
    public class Circle implements Shape {
        private Point2D center;
        private double radius;
        private Color color;
    
        public Circle(Color color, double x, double y, double radius) {
            this.color = color;
            this.center = new Point2D(x, y);
            this.radius = radius;
        }
    
        @Override
        public int pointsCount() {
            return 1;  // Un cercle n'a qu'un centre
        }
    
        @Override
        public Point2D point(int index) {
            if (index == 0) {
                return center;
            }
            throw new IndexOutOfBoundsException("Circle has only one center point.");
        }
    
        @Override
        public void draw(GraphicsContext context) {
            context.setStroke(color);
            context.strokeOval(center.getX() - radius, center.getY() - radius,
                    radius * 2, radius * 2);
        }
    }