Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace rectanglePosition
- {
- public class Rectangle
- {
- public double Left { get; set; }
- public double Top { get; set; }
- public double Width { get; set; }
- public double Heigth { get; set; }
- public double Right
- {
- get
- {
- return Left + Width;
- }
- }
- public double Bottom
- {
- get
- {
- return Math.Abs(Math.Abs(Top) - Math.Abs(Heigth));
- }
- }
- public static Rectangle ReadRectangle()
- {
- var rectangleParts = Console.ReadLine().Split().Select(double.Parse).ToList();
- return new Rectangle
- {
- Left = rectangleParts[0],
- Top = rectangleParts[1],
- Width = rectangleParts[2],
- Heigth = rectangleParts[3]
- };
- }
- public static bool IsInside(Rectangle firstRectangle, Rectangle secondRectangle)
- {
- if ( firstRectangle.Left >= secondRectangle.Left
- && firstRectangle.Right <= secondRectangle.Right
- && firstRectangle.Top <= secondRectangle.Top
- && firstRectangle.Bottom <= secondRectangle.Bottom)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- public class rectanglePosition
- {
- public static void Main()
- {
- var firstRectangle = Rectangle.ReadRectangle();
- var secondRectangle = Rectangle.ReadRectangle();
- var isInside = Rectangle.IsInside(firstRectangle, secondRectangle);
- if ( isInside )
- {
- Console.WriteLine("Inside");
- }
- else
- {
- Console.WriteLine("Not inside");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement