package ru.vsu.cs.ist.melnik.vladimir.tasks.task3_49;

import ru.vsu.cs.ist.melnik.vladimir.tasks.task3_49.figure.Circle;
import ru.vsu.cs.ist.melnik.vladimir.tasks.task3_49.figure.HorizontalLine;
import ru.vsu.cs.ist.melnik.vladimir.tasks.task3_49.figure.HorizontalParabola;
import ru.vsu.cs.ist.melnik.vladimir.tasks.task3_49.figure.Rectangle;

public class Task3_49 {
    public static HorizontalParabola horizontalParabola;
    public static Rectangle rectangle;
    public static Circle circle;
    public static HorizontalLine horizontalLineRight;
    public static HorizontalLine horizontalLineLeft;

    public static void main(String[] args) {
        horizontalParabola = new HorizontalParabola(1, 2.5, 1);
        rectangle = new Rectangle(-4, -2, 2, -3);
        circle = new Circle(3, -4, 2);
        horizontalLineRight = new HorizontalLine(4, 0, 2.5);
        horizontalLineLeft = new HorizontalLine(4, 13, -2);
        System.out.println(getColor(4.2, 3));


    }

    public static SimpleColor getColor(double x, double y) {


        if (horizontalLineLeft.isPointRightLine(x,y) && circle.isPointInside(x,y)) {
            return SimpleColor.ORANGE;
        }

        return SimpleColor.GREEN;
    }

}


package ru.vsu.cs.ist.melnik.vladimir.tasks.task3_49.figure;

public class HorizontalLine {

    public double x0;
    public double y0;
    public double a;

    public HorizontalLine(double x0, double y0, double a) {
        this.x0 = x0;
        this.y0 = y0;
        this.a = a;
    }

    /**
     * Проверяет, находится ли точка (x, y) выше линии
     */
    public boolean isPointAboveLine(double x, double y) {
        return y > a * (x - x0) + y0;
    }

    /**
     * Проверяет, находится ли точка (x, y) ниже линии
     */
    public boolean isPointUnderLine(double x, double y) {
        return y < a * (x - x0) + y0;
    }

    public boolean isPointRightLine(double x, double y) {
        return x > a * (y - y0) + x0;
    }
    public boolean isPointLeftLine(double x, double y) {
        return x < a * (y - y0) + x0;
    }

}


package ru.vsu.cs.ist.melnik.vladimir.tasks.task3_49.figure;

public class HorizontalParabola {
    double y0;
    double x0;
    double a;

    public HorizontalParabola(double x0, double y0, double a) {
        this.x0 = x0;
        this.y0 = y0;
        this.a = a;
    }


    public boolean isPointOfParabola(double x, double y) {
        // x = -Math.pow((0.5 * y - 2.5), 2) + 1
        // x = -Math.pow((a * y + y0), 2) + x0
        return x == -Math.pow((a * y + y0), 2) + x0;
    }


}


package ru.vsu.cs.ist.melnik.vladimir.tasks.task3_49.figure;

public class Circle {

    double x0, y0, R;

    public Circle(double x0, double y0, double R) {
        this.x0 = x0;
        this.y0 = y0;
        this.R = R;
    }

    public boolean isPointInside(double x, double y) {
        return Math.pow(x - x0, 2) + Math.pow(y - y0, 2) == Math.pow(R, 2);
    }
}

package ru.vsu.cs.ist.melnik.vladimir.tasks.task3_49.figure;

public class Rectangle {
    HorizontalLine upLine;
    HorizontalLine downLine;
    VerticalLine leftLine;
    VerticalLine rightLine;

    public Rectangle(double left, double right, double upper, double lower) {
        upLine = new HorizontalLine(0, upper, 0);
        downLine = new HorizontalLine(0, lower, 0);
        leftLine = new VerticalLine(left, 0, 0);
        rightLine = new VerticalLine(right, 0, 0);

    }


    public boolean isPointRightOfParabola(double x, double y) {
        return upLine.isPointUnderLine(x, y) && downLine.isPointAboveLine(x, y)
                && leftLine.isPointRightLine(x, y) && rightLine.isPointLeftLine(x, y);
    }

}


why not orange???