Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. package com.tasks.Task3;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Task3 {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. System.out.print("Введите Х точки = ");
  10. double pointX = scanner.nextDouble();
  11. System.out.print("Введите У точки = ");
  12. double pointY = scanner.nextDouble();
  13.  
  14. System.out.println(getColor(pointX, pointY));
  15. }
  16.  
  17. private static SimpleColor getColor(double x, double y) {
  18. System.out.printf("(%.2f, %.2f) -> ", x, y);
  19. HorizontalParabola HP1 = new HorizontalParabola(2, 3, 0.5);
  20. HorizontalParabola HP2 = new HorizontalParabola(-4, -2, 0.5);
  21. VerticalParabola VP1 = new VerticalParabola(3, 1, 1);
  22. Circle С1 = new Circle(-2, -4, 5);
  23. Line L1 = new Line(1, 3, -4);
  24.  
  25. if (HP1.isPointRightOfParabola(x, y) && VP1.isPointAboveParabola(x, y)) {
  26. return SimpleColor.BLUE;
  27. }
  28. if (HP1.isPointRightOfParabola(x, y) && HP2.isPointRightOfParabola(x, y)) {
  29. return SimpleColor.ORANGE;
  30. }
  31. if (HP1.isPointRightOfParabola(x, y) && !HP2.isPointRightOfParabola(x, y) && !VP1.isPointAboveParabola(x, y)) {
  32. return SimpleColor.YELLOW;
  33. }
  34. if (!HP1.isPointRightOfParabola(x, y) && !HP2.isPointRightOfParabola(x, y) && VP1.isPointAboveParabola(x, y)) {
  35. return SimpleColor.ORANGE;
  36. }
  37. if (HP2.isPointRightOfParabola(x, y) && С1.isPointInsideCircle(x, y) && !L1.isPointAboveLine(x, y)) {
  38. return SimpleColor.BLUE;
  39. }
  40. if (HP2.isPointRightOfParabola(x, y) && С1.isPointInsideCircle(x, y) && L1.isPointAboveLine(x, y)) {
  41. return SimpleColor.YELLOW;
  42. }
  43. if (HP2.isPointRightOfParabola(x, y) && !С1.isPointInsideCircle(x, y) && !L1.isPointAboveLine(x, y)) {
  44. return SimpleColor.GRAY;
  45. }
  46. if (HP2.isPointRightOfParabola(x, y) && VP1.isPointAboveParabola(x, y)) {
  47. return SimpleColor.BLUE;
  48. }
  49. if (С1.isPointInsideCircle(x, y) && !HP2.isPointRightOfParabola(x, y) && !L1.isPointAboveLine(x, y)) {
  50. return SimpleColor.YELLOW;
  51. }
  52. if (!HP2.isPointRightOfParabola(x, y) && !L1.isPointAboveLine(x, y)) {
  53. return SimpleColor.YELLOW;
  54. }
  55. if (L1.isPointAboveLine(x, y) && y > 1 && x < 2.5 && !VP1.isPointAboveParabola(x, y)) {
  56. return SimpleColor.BLUE;
  57. }
  58. if (L1.isPointAboveLine(x, y) && y < 5 && !HP2.isPointRightOfParabola(x, y)) {
  59. return SimpleColor.GREEN;
  60. }
  61. return SimpleColor.YELLOW;
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement