public bool FitsInRectangle(Rectangle rectangleToFitIn) { return AreaCondition(rectangleToFitIn) && DiameterCondition(rectangleToFitIn) && PerimeterCondition(rectangleToFitIn) && ThicknessCondition(rectangleToFitIn) && WCarversCondition(rectangleToFitIn); }
public bool WCarversCondition(Rectangle rectangle) { var hasShorterWidth = width <= rectangle.width; var hasShorterHeight = height <= rectangle.height; var wCarversFirstConditionWasMet = hasShorterWidth && hasShorterHeight; if (wCarversFirstConditionWasMet) { return true; } if (JohnEWetzelsEquation(width, height, rectangle.width, rectangle.height)) { return true; } return false; }
static void TestC() { Console.WriteLine("Test C"); var rectA = new Rectangle(8, 6); var rectB = new Rectangle(8, 6); if (rectA.FitsInRectangle(rectB)) { Console.WriteLine("Test C Passed"); Console.WriteLine("Rect A fits in Rect B"); } else { Console.WriteLine("Test C Failed"); Console.WriteLine("Rect A DOES NOT fit in Rect B"); } Console.WriteLine(); }
static void TestB() { Console.WriteLine("Test B"); var rectA = new Rectangle(88, 13); var rectB = new Rectangle(81, 59); if (rectA.FitsInRectangle(rectB)) { Console.WriteLine("Test B Failed"); Console.WriteLine("Rect A fits in Rect B"); } else { Console.WriteLine("Test B Passed"); Console.WriteLine("Rect A DOES NOT fit in Rect B"); } Console.WriteLine(); }
public bool ThicknessCondition(Rectangle rectangle) { return ThickistSide <= rectangle.ThickistSide; }
public bool PerimeterCondition(Rectangle rectangle) { return Perimeter <= rectangle.Perimeter; }
public bool DiameterCondition(Rectangle rectangle) { return Diameter <= rectangle.Diameter; }
public bool AreaCondition(Rectangle rectangle) { return Area <= rectangle.Area; }