Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace rectanglePosition
  5. {
  6. public class Rectangle
  7. {
  8. public double Left { get; set; }
  9. public double Top { get; set; }
  10. public double Width { get; set; }
  11. public double Heigth { get; set; }
  12.  
  13. public double Right
  14. {
  15. get
  16. {
  17. return Left + Width;
  18. }
  19. }
  20.  
  21. public double Bottom
  22. {
  23. get
  24. {
  25. return Math.Abs(Math.Abs(Top) - Math.Abs(Heigth));
  26. }
  27. }
  28.  
  29. public static Rectangle ReadRectangle()
  30. {
  31. var rectangleParts = Console.ReadLine().Split().Select(double.Parse).ToList();
  32.  
  33. return new Rectangle
  34. {
  35. Left = rectangleParts[0],
  36. Top = rectangleParts[1],
  37. Width = rectangleParts[2],
  38. Heigth = rectangleParts[3]
  39. };
  40. }
  41.  
  42. public static bool IsInside(Rectangle firstRectangle, Rectangle secondRectangle)
  43. {
  44. if ( firstRectangle.Left >= secondRectangle.Left
  45. && firstRectangle.Right <= secondRectangle.Right
  46. && firstRectangle.Top <= secondRectangle.Top
  47. && firstRectangle.Bottom <= secondRectangle.Bottom)
  48. {
  49. return true;
  50. }
  51.  
  52. else
  53. {
  54. return false;
  55. }
  56.  
  57.  
  58. }
  59. }
  60.  
  61. public class rectanglePosition
  62. {
  63. public static void Main()
  64. {
  65. var firstRectangle = Rectangle.ReadRectangle();
  66. var secondRectangle = Rectangle.ReadRectangle();
  67.  
  68. var isInside = Rectangle.IsInside(firstRectangle, secondRectangle);
  69.  
  70. if ( isInside )
  71. {
  72. Console.WriteLine("Inside");
  73. }
  74. else
  75. {
  76. Console.WriteLine("Not inside");
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement