public bool PushInCheck(Cuboid fridge, Circle doorway) { Rectangle fridgeMinSides = fridge.SearchMinSides(); if ((Math.Pow(fridgeMinSides.Height, 2) + Math.Pow(fridgeMinSides.Width, 2)) <= doorway.Diameter) { return(true); } else { return(false); } }
public bool PushInCheck(Cuboid fridge, Rectangle doorway) { Rectangle fridgeMinSides = fridge.SearchMinSides(); if ((fridgeMinSides.Height <= doorway.Height && fridgeMinSides.Width <= doorway.Width) || (fridgeMinSides.Height <= doorway.Width && fridgeMinSides.Width <= doorway.Height)) { return(true); } else { return(false); } }
private void ButtonCheck_Click(object sender, RoutedEventArgs e) { var solution = new FridgePushIn(); try { switch (comboBoxFridgeShape.SelectedIndex) { case 0: // check if all parameters of the fridge were entered if (textBoxFridgeHeight.Text == string.Empty || textBoxFridgeLength.Text == string.Empty || textBoxFridgeWidth.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxFridgeHeight.Text) == 0 || double.Parse(textBoxFridgeLength.Text) == 0 || double.Parse(textBoxFridgeWidth.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } else { var checkingFridge = new Cuboid(double.Parse(textBoxFridgeHeight.Text), double.Parse(textBoxFridgeLength.Text), double.Parse(textBoxFridgeWidth.Text)); var check = false; if (comboBoxDoorway.SelectedItem == comboBoxDoorway.Items[0]) { // check if all parameters of the doorway were entered if (textBoxDoorwayHeight.Text == string.Empty || textBoxDoorwayWidth.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxDoorwayHeight.Text) == 0 || double.Parse(textBoxDoorwayWidth.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var checkingHole = new Rectangle(double.Parse(textBoxDoorwayHeight.Text), double.Parse(textBoxDoorwayWidth.Text)); check = solution.PushInCheck(checkingFridge, checkingHole); } if (comboBoxDoorway.SelectedItem == comboBoxDoorway.Items[1]) { // check if all parameters of the window were entered if (textBoxDoorwayHeight.Text == string.Empty || textBoxDoorwayWidth.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxDoorwayHeight.Text) == 0 || double.Parse(textBoxDoorwayWidth.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var checkingHole = new Rectangle(double.Parse(textBoxDoorwayHeight.Text), double.Parse(textBoxDoorwayWidth.Text)); check = solution.PushInCheck(checkingFridge, checkingHole); } if (comboBoxDoorway.SelectedItem == comboBoxDoorway.Items[2]) { // check if all parameters of the window were entered if (textBoxWindowDiameter.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxWindowDiameter.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var checkingHole = new Circle(double.Parse(textBoxWindowDiameter.Text)); check = solution.PushInCheck(checkingFridge, checkingHole); } //output results if (check) { MessageBox.Show(positiveMessage, resultTitle, MessageBoxButton.OK, MessageBoxImage.Asterisk); } else { MessageBox.Show(negativeMessage, resultTitle, MessageBoxButton.OK, MessageBoxImage.Stop); } } break; case 1: if (textBoxFridgeHeight.Text == string.Empty || textBoxFridgeDiameter.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxFridgeHeight.Text) == 0 || double.Parse(textBoxFridgeDiameter.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } else { var checkingFridge = new Cylinder(double.Parse(textBoxFridgeHeight.Text), double.Parse(textBoxFridgeDiameter.Text)); var check = false; if (comboBoxDoorway.SelectedItem == comboBoxDoorway.Items[0]) { // check if all parameters of the doorway were entered if (textBoxDoorwayHeight.Text == string.Empty || textBoxDoorwayWidth.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxDoorwayHeight.Text) == 0 || double.Parse(textBoxDoorwayWidth.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var checkingHole = new Rectangle(double.Parse(textBoxDoorwayHeight.Text), double.Parse(textBoxDoorwayWidth.Text)); //var solution = new FridgePushIn(); check = solution.PushInCheck(checkingFridge, checkingHole); } if (comboBoxDoorway.SelectedItem == comboBoxDoorway.Items[1]) { // check if all parameters of the window were entered if (textBoxDoorwayHeight.Text == string.Empty || textBoxDoorwayWidth.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxDoorwayHeight.Text) == 0 || double.Parse(textBoxDoorwayWidth.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var checkingHole = new Rectangle(double.Parse(textBoxDoorwayHeight.Text), double.Parse(textBoxDoorwayWidth.Text)); check = solution.PushInCheck(checkingFridge, checkingHole); } if (comboBoxDoorway.SelectedItem == comboBoxDoorway.Items[2]) { // check if all parameters of the window were entered if (textBoxWindowDiameter.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxWindowDiameter.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var checkingHole = new Circle(double.Parse(textBoxWindowDiameter.Text)); check = solution.PushInCheck(checkingFridge, checkingHole); } //output results if (check) { MessageBox.Show(positiveMessage, resultTitle, MessageBoxButton.OK, MessageBoxImage.Asterisk); } else { MessageBox.Show(negativeMessage, resultTitle, MessageBoxButton.OK, MessageBoxImage.Stop); } } break; case 2: if (textBoxFridgeDiameter.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxFridgeDiameter.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } else { var checkingFridge = new Sphere(double.Parse(textBoxFridgeDiameter.Text)); var check = false; if (comboBoxDoorway.SelectedItem == comboBoxDoorway.Items[0]) { // check if all parameters of the doorway were entered if (textBoxDoorwayHeight.Text == string.Empty || textBoxDoorwayWidth.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxDoorwayHeight.Text) == 0 || double.Parse(textBoxDoorwayWidth.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var checkingHole = new Rectangle(double.Parse(textBoxDoorwayHeight.Text), double.Parse(textBoxDoorwayWidth.Text)); check = solution.PushInCheck(checkingFridge, checkingHole); } if (comboBoxDoorway.SelectedItem == comboBoxDoorway.Items[1]) { // check if all parameters of the window were entered if (textBoxDoorwayHeight.Text == string.Empty || textBoxDoorwayWidth.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxDoorwayHeight.Text) == 0 || double.Parse(textBoxDoorwayWidth.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var checkingHole = new Rectangle(double.Parse(textBoxDoorwayHeight.Text), double.Parse(textBoxDoorwayWidth.Text)); check = solution.PushInCheck(checkingFridge, checkingHole); } if (comboBoxDoorway.SelectedItem == comboBoxDoorway.Items[2]) { // check if all parameters of the window were entered if (textBoxWindowDiameter.Text == string.Empty) { MessageBox.Show(allParametersMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // check if user entered zero as size if (double.Parse(textBoxWindowDiameter.Text) == 0) { MessageBox.Show(zeroMessage, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var checkingHole = new Circle(double.Parse(textBoxWindowDiameter.Text)); check = solution.PushInCheck(checkingFridge, checkingHole); } //output results if (check) { MessageBox.Show(positiveMessage, resultTitle, MessageBoxButton.OK, MessageBoxImage.Asterisk); } else { MessageBox.Show(negativeMessage, resultTitle, MessageBoxButton.OK, MessageBoxImage.Stop); } } break; } } //exception if input numbers are to big catch (OverflowException ex) { MessageBox.Show(ex.Message, errorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }