Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace WorkingWithAbstactions
- {
- class Rectangle
- {
- public Rectangle (Point TopLeft,Point BottomRight)
- {
- this.TopLeftPoint = TopLeft;
- this.BottomRightPoint = BottomRight;
- }
- public Rectangle(int leftX,int leftY,int rightX,int rightY)
- {
- this.TopLeftPoint = new Point(leftX, leftY);
- this.BottomRightPoint = new Point(rightX, rightY);
- }
- public Rectangle()
- {
- }
- public Point TopLeftPoint { get; set; }
- public Point BottomRightPoint{ get; set; }
- public bool Contains(Point point)
- {
- if ( point.X >= TopLeftPoint.X &&
- point.X <= BottomRightPoint.X &&
- point.Y <= TopLeftPoint.Y &&
- point.Y >= BottomRightPoint.Y)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- class Point
- {
- public Point(int x,int y)
- {
- this.X = x;
- this.Y = y;
- }
- public Point()
- {
- }
- public int X { get; set; }
- public int Y { get; set; }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Rectangle rectangle = new Rectangle();
- Point topLeft = new Point();
- Point bottomRight = new Point();
- int[] coordinates = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int n = int.Parse(Console.ReadLine());
- int topLeftX = coordinates[0];
- int topLeftY = coordinates[1];
- int bottomRightX = coordinates[2];
- int bottomRightY = coordinates[3];
- topLeft.X = topLeftX;
- topLeft.Y = topLeftY;
- bottomRight.X = bottomRightX;
- bottomRight.Y = bottomRightY;
- rectangle.TopLeftPoint = topLeft;
- rectangle.BottomRightPoint = bottomRight;
- Point point = new Point();
- for (int i = 0;i < n; i++)
- {
- int[] points = Console.ReadLine().Split().Select(int.Parse).ToArray();
- point.X = points[0];
- point.Y = points[1];
- Console.WriteLine(rectangle.Contains(point));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment