Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2020
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. package com.abstraction.Problem02.PointInRectangle;
  2.  
  3. import java.util.*;
  4.  
  5. public class Main {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String rectangleCoordinates = scanner.nextLine();
  9.  
  10.         int input[] = Arrays.stream(rectangleCoordinates.split(" "))
  11.                 .mapToInt(Integer::parseInt)
  12.                 .toArray();
  13.  
  14.         Rectangle rectangle = new Rectangle(input[0], input[1], input[2], input[3]);
  15.  
  16.         int numberOfPointsToCheck = Integer.parseInt(scanner.nextLine());
  17.  
  18.         for (int i = 0; i < numberOfPointsToCheck; i++) {
  19.             int[] pointCoordinates = Arrays.stream(scanner.nextLine().split(" "))
  20.                     .mapToInt(Integer::parseInt)
  21.                     .toArray();
  22.  
  23.             Point point = new Point(pointCoordinates[0], pointCoordinates[1]);
  24.  
  25.             System.out.println(rectangle.contains(point));
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement