private void EnterButton_Click(object sender, EventArgs e) { int noOfItems = string.IsNullOrEmpty(itemTextBox.Text) ? 0 : Convert.ToInt32(itemTextBox.Text); int weightOfItems = string.IsNullOrEmpty(weightTextBox.Text) ? 0 : Convert.ToInt32(weightTextBox.Text); itemTextBox.Clear(); weightTextBox.Clear(); double totalWeight = noOfItems * weightOfItems; if (!aRefrigerator.CheckValidity(totalWeight)) { MessageBox.Show("Weight limit exceeded"); return; } aRefrigerator.SetWeight(noOfItems, weightOfItems); DisplayCurrentAndRemainingWeight(); DisplayRefrigeratorDetails(); }