Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Linq;
- namespace _06._Rectangle_Position
- {
- public class Rectangle
- {
- public int Top { get; set; }
- public int Left { get; set; }
- public int Width { get; set; }
- public int Height { get; set; }
- public int Right { get { return Left + Width; } }
- public int Bottom { get { return Top + Height; } }
- public bool IsInside(Rectangle r)
- {
- return (r.Left <= Left) && (r.Right >= Right) &&
- (r.Top <= Top) && (r.Bottom >= Bottom);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Rectangle r1 = ReadRectangle(), r2 = ReadRectangle();
- Console.WriteLine(r1.IsInside(r2) ? "Inside" :
- "Not inside");
- }
- public static Rectangle ReadRectangle()
- {
- var size = Console.ReadLine().Split().Select(int.Parse);
- Rectangle rectangle = new Rectangle()
- {
- Left = size.First(),
- Top = size.Skip(1).First(),
- Width = size.Skip(2).First(),
- Height = size.Skip(3).First()
- };
- return rectangle;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement