// NON-DEFAULT CONSTRUCTOR public PackageInfoClass(PackageInfoClass copyPackage) { this.pckgContents = copyPackage.pckgContents; this.shipMiles = copyPackage.shipMiles; this.pckgLength = copyPackage.pckgLength; this.pckgWidth = copyPackage.pckgWidth; this.pckgHeight = copyPackage.pckgHeight; this.pckgWeight = copyPackage.pckgWeight; }
public void submitBtn_Click(object sender, EventArgs e) { emptyField = true; PackageInfoClass package = new PackageInfoClass(); if (pckgCotentsTxtBx.Text == string.Empty) { MessageBox.Show("Please enter the content of your package."); pckgCotentsTxtBx.Focus(); } else if (pckgLengthTxtBx.Text == string.Empty || float.Parse(pckgLengthTxtBx.Text) < 1) { MessageBox.Show("Please enter the length of your package."); pckgLengthTxtBx.Focus(); } else if (pckgHeightTxtBx.Text == string.Empty || float.Parse(pckgHeightTxtBx.Text) < 1) { MessageBox.Show("Please enter the height of your package."); pckgHeightTxtBx.Focus(); } else if (shipDistanceTxtBx.Text == string.Empty || int.Parse(shipDistanceTxtBx.Text) < 1) { MessageBox.Show("Please enter the distance of your package's destination in miles."); shipDistanceTxtBx.Focus(); } else if (pckgWeightTxtBx.Text == string.Empty || float.Parse(pckgWeightTxtBx.Text) < .01) { MessageBox.Show("Please enter the weight of your package. Weight must be greater than 0."); pckgWeightTxtBx.Focus(); } else if (pckgWidthTxtBox.Text == string.Empty || float.Parse(pckgWidthTxtBox.Text) < 1) { MessageBox.Show("Please enter the width of your package. Width must be greater than 0."); pckgWidthTxtBox.Focus(); } else { emptyField = false; shipCostGrp.Enabled = true; package.GetPackageContents = pckgCotentsTxtBx.Text; package.GetShipMiles = int.Parse(shipDistanceTxtBx.Text); package.GetPckgLength = float.Parse(pckgLengthTxtBx.Text); package.GetPckgWidth = float.Parse(pckgWidthTxtBox.Text); package.GetPckgHeight = float.Parse(pckgHeightTxtBx.Text); package.GetPckgWeight = float.Parse(pckgWeightTxtBx.Text); // Call the Calculate Volume Method from PackageInfoClass pckgSizeTxtBx.Text = "Your package is " + String.Format("{0:0.00}", package.CalculateVolume()) + " cubic inches."; // Call the Calculate Cost Method from the PackageInfoClass shipCostTxtBx.Text = "Your package will cost $" + String.Format("{0:0.00}", package.CalculateCost()) + " to ship."; } }