Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tasks.Task3;
- import java.util.Scanner;
- public class Task3 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.print("Введите Х точки = ");
- double pointX = scanner.nextDouble();
- System.out.print("Введите У точки = ");
- double pointY = scanner.nextDouble();
- System.out.println(getColor(pointX, pointY));
- }
- private static SimpleColor getColor(double x, double y) {
- System.out.printf("(%.2f, %.2f) -> ", x, y);
- HorizontalParabola HP1 = new HorizontalParabola(2, 3, 0.5);
- HorizontalParabola HP2 = new HorizontalParabola(-4, -2, 0.5);
- VerticalParabola VP1 = new VerticalParabola(3, 1, 1);
- Circle С1 = new Circle(-2, -4, 5);
- Line L1 = new Line(1, 3, -4);
- if (HP1.isPointRightOfParabola(x, y) && VP1.isPointAboveParabola(x, y)) {
- return SimpleColor.BLUE;
- }
- if (HP1.isPointRightOfParabola(x, y) && HP2.isPointRightOfParabola(x, y)) {
- return SimpleColor.ORANGE;
- }
- if (HP1.isPointRightOfParabola(x, y) && !HP2.isPointRightOfParabola(x, y) && !VP1.isPointAboveParabola(x, y)) {
- return SimpleColor.YELLOW;
- }
- if (!HP1.isPointRightOfParabola(x, y) && !HP2.isPointRightOfParabola(x, y) && VP1.isPointAboveParabola(x, y)) {
- return SimpleColor.ORANGE;
- }
- if (HP2.isPointRightOfParabola(x, y) && С1.isPointInsideCircle(x, y) && !L1.isPointAboveLine(x, y)) {
- return SimpleColor.BLUE;
- }
- if (HP2.isPointRightOfParabola(x, y) && С1.isPointInsideCircle(x, y) && L1.isPointAboveLine(x, y)) {
- return SimpleColor.YELLOW;
- }
- if (HP2.isPointRightOfParabola(x, y) && !С1.isPointInsideCircle(x, y) && !L1.isPointAboveLine(x, y)) {
- return SimpleColor.GRAY;
- }
- if (HP2.isPointRightOfParabola(x, y) && VP1.isPointAboveParabola(x, y)) {
- return SimpleColor.BLUE;
- }
- if (С1.isPointInsideCircle(x, y) && !HP2.isPointRightOfParabola(x, y) && !L1.isPointAboveLine(x, y)) {
- return SimpleColor.YELLOW;
- }
- if (!HP2.isPointRightOfParabola(x, y) && !L1.isPointAboveLine(x, y)) {
- return SimpleColor.YELLOW;
- }
- if (L1.isPointAboveLine(x, y) && y > 1 && x < 2.5 && !VP1.isPointAboveParabola(x, y)) {
- return SimpleColor.BLUE;
- }
- if (L1.isPointAboveLine(x, y) && y < 5 && !HP2.isPointRightOfParabola(x, y)) {
- return SimpleColor.GREEN;
- }
- return SimpleColor.YELLOW;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement