// Precondition: Insert, Letter menu item activated // Postcondition: The Letter dialog box is displayed. If data entered // are OK, a Letter is created and added to the list // of parcels private void letterToolStripMenuItem_Click(object sender, EventArgs e) { LetterForm letterForm; // The letter dialog box form DialogResult result; // The result of showing form as dialog if (upv.AddressCount < LetterForm.MIN_ADDRESSES) // Make sure we have enough addresses { MessageBox.Show("Need " + LetterForm.MIN_ADDRESSES + " addresses to create letter!", "Addresses Error"); return; } letterForm = new LetterForm(upv.AddressList); // Send list of addresses result = letterForm.ShowDialog(); if (result == DialogResult.OK) // Only add if OK { try { // For this to work, LetterForm's combo boxes need to be in same // order as upv's AddressList upv.AddLetter(upv.AddressAt(letterForm.OriginAddressIndex), upv.AddressAt(letterForm.DestinationAddressIndex), decimal.Parse(letterForm.FixedCostText)); // Letter to be inserted } catch (FormatException) // This should never happen if form validation works! { MessageBox.Show("Problem with Letter Validation!", "Validation Error"); } } letterForm.Dispose(); // Best practice for dialog boxes }
// Precondition: Insert, Letter menu item activated // Postcondition: The Letter dialog box is displayed. If data entered // are OK, a Letter is created and added to the list // of parcels private void letterToolStripMenuItem_Click(object sender, EventArgs e) { LetterForm letterForm; // The letter dialog box form DialogResult result; // The result of showing form as dialog decimal fixedCost; // The letter's cost if (upv.AddressCount < LetterForm.MIN_ADDRESSES) // Make sure we have enough addresses { MessageBox.Show("Need " + LetterForm.MIN_ADDRESSES + " addresses to create letter!", "Addresses Error"); return; // Exit now since can't create valid letter } letterForm = new LetterForm(upv.AddressList); // Send list of addresses result = letterForm.ShowDialog(); if (result == DialogResult.OK) // Only add if OK { if (decimal.TryParse(letterForm.FixedCostText, out fixedCost)) { // For this to work, LetterForm's combo boxes need to be in same // order as upv's AddressList upv.AddLetter(upv.AddressAt(letterForm.OriginAddressIndex), upv.AddressAt(letterForm.DestinationAddressIndex), fixedCost); // Letter to be inserted } else // This should never happen if form validation works! { MessageBox.Show("Problem with Letter Validation!", "Validation Error"); } } letterForm.Dispose(); // Best practice for dialog boxes // Alternatively, use with using clause as in Ch. 17 }
// Precondition: None // Postcondition: Helper method to add test parcels to the upv private void AddLetters() { // Add test data to upv list upv.AddGroundPackage(upv.AddressAt(0), upv.AddressAt(7), 12, 4, 6, 2); upv.AddNextDayAirPackage(upv.AddressAt(1), upv.AddressAt(6), 25, 5, 5, 15, 35.00m); upv.AddLetter(upv.AddressAt(2), upv.AddressAt(5), 1.25m); upv.AddLetter(upv.AddressAt(3), upv.AddressAt(4), 1.25m); }
// Precondition: The Insert >> Letter menu item has been selected // Postcondition: A dialog box prompts the user for new Letter information. // If the user submits, a new Letter object is created. private void letterToolStripMenuItem_Click(object sender, EventArgs e) { AddLetterForm addLetter = new AddLetterForm(upv.AddressList); // Calls Add Letter Form DialogResult result = addLetter.ShowDialog(); // Result from dialog - OK/Cancel? if (result == DialogResult.OK) // Letter object is created if user selects OK from dialog box { upv.AddLetter(upv.AddressAt(addLetter.ReturnAddress), upv.AddressAt(addLetter.DestinationAddress), decimal.Parse(addLetter.FixedCost)); } }
//Precondition: Origin address, destination address, and fixed cost must have values //Postconditon: Shows form and creates a letter private void letterToolStripMenuItem_Click(object sender, EventArgs e) { LetterForm lfrm = new LetterForm(upv.AddressList); //New LetterForm object DialogResult result = lfrm.ShowDialog(); if (result == DialogResult.OK) { upv.AddLetter(upv.AddressAt(lfrm.OriginValue), upv.AddressAt(lfrm.DestValue), decimal.Parse(lfrm.FixedCost)); } lfrm.Dispose(); }
public Prog2Form() { InitializeComponent(); upv.AddAddress(" John Smith ", " 123 Any St. ", " Apt. 45 ", " Louisville ", " KY ", 40202); // Test Address 1 upv.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90210); // Test Address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 upv.AddAddress("Ivy Cat", "1234 Catnip St.", "Meowville", "KY", 56789); // Test Address 5 upv.AddAddress("Mia Dog", "9876 Bone St.", "Growlsville", "NY", 78463); // Test Address 6 upv.AddAddress("Rex Paw", "321 Treats Blvd.", "Apt. 6", "Barksville", "TN", 31254); // Test Address 7 upv.AddAddress("Athena Slithers", "587 Snake Rd.", "Apt. 23", "Hissington", "LA", 87436); // Test Address 8 upv.AddLetter(upv.AddressAt(0), upv.AddressAt(1), 3.50M); // Test Letter 1 upv.AddLetter(upv.AddressAt(2), upv.AddressAt(3), 4.50M); // Test Letter 2 upv.AddLetter(upv.AddressAt(4), upv.AddressAt(5), 10M); // Test Letter 3 upv.AddLetter(upv.AddressAt(6), upv.AddressAt(7), 2M); // Test Letter 4 }
//Precondition: None //Postcondition: creates Address' and Letters to their respective // list using the Add(Address/Letter) method public Prog2Form() { InitializeComponent(); upv = new UserParcelView(); upv.AddAddress("John Smith", "123 Any St.", "Apt. 45", "Louisville", "KY", 40202); // test address 1 upv.AddAddress("Jane Doe", "987 Main St.", "", "Beverly Hills", "CA", 90210); // test address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // test address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // test address 4 upv.AddAddress("Stan Marsh", "ShTapa Town", "4321 Your Street", "Pittsburgh", "Pennsylvania", 15201); // test address 5 upv.AddAddress("Eric Cartman", "South Park Elementary", "Detention Room 102", "New York City", "New York", 10001); // test address 6 upv.AddAddress("Kenny McCormick", "SoDoSoapa", "1111 Gheto Avenue", "South Park", "Colorado", 80019); // test address 7 upv.AddAddress("Kyle Broflovski", "The Church of God", "5676 Jewish Lane", "Jersey City", "New Jersey", 07208); // test address 8 upv.AddLetter(upv.AddressAt(1), upv.AddressAt(0), 2.50M); //test letter 1 upv.AddLetter(upv.AddressAt(3), upv.AddressAt(4), 1.50M); //test letter 2 upv.AddLetter(upv.AddressAt(2), upv.AddressAt(5), 2.00M); //test letter 3 upv.AddLetter(upv.AddressAt(7), upv.AddressAt(6), 0.75M); //test letter 4 }
// Precondition: None // Postcondition: Fills form with fake data private void pseudoData() { //Add the addresses to the user factory UserParcelView.AddAddress("Gary Smith", "10405 Thrift Drive", "Apt 105", "Louisvile", "KY", 40223); UserParcelView.AddAddress("Bob Jones", "3603 Spring Villa Circle", "Apt 5", "Louisvile", "KY", 40223); UserParcelView.AddAddress("Alan Gavin", "U of L", "Louisvile", "KY", 40291); UserParcelView.AddAddress("Gray Thomas", "18 Lane Avenue", "Louisvile", "KY", 42044); UserParcelView.AddAddress("This Guy", "222 Road Road", "Apt 105", "Louisvile", "KY", 40223); UserParcelView.AddAddress("That Guy", "123 Ave Street", "Apt 105", "Louisvile", "KY", 40223); //Add the letters to the user factory UserParcelView.AddLetter(UserParcelView.AddressAt(0), UserParcelView.AddressAt(5), 12.50m); UserParcelView.AddLetter(UserParcelView.AddressAt(1), UserParcelView.AddressAt(5), 9.50m); UserParcelView.AddLetter(UserParcelView.AddressAt(2), UserParcelView.AddressAt(3), 12.50m); UserParcelView.AddLetter(UserParcelView.AddressAt(3), UserParcelView.AddressAt(4), 122.50m); UserParcelView.AddLetter(UserParcelView.AddressAt(0), UserParcelView.AddressAt(2), 122.50m); }
//Precondition: Letter menu item is clicked //Postcondition: Input from letter form is stored and sent to UPV. private void letterToolStripMenuItem_Click(object sender, EventArgs e) { LetterForm LetterForm = new LetterForm(upv.AddressList); DialogResult result; int originIndex; int destinationIndex; decimal fixedCost; result = LetterForm.ShowDialog(); if (result == DialogResult.OK) { originIndex = LetterForm.OriginIndex; destinationIndex = LetterForm.DestIndex; fixedCost = decimal.Parse(LetterForm.LetterFixedCost); upv.AddLetter(upv.AddressAt(originIndex), upv.AddressAt(destinationIndex), fixedCost); } }
public Prog2Form() { InitializeComponent(); upv = new UserParcelView(); // Test Data - Magic Numbers OK upv.AddAddress("John Smith", "123 Any St.", "Apt. 45", "Louisville", "KY", 40202); // Test Address 1 upv.AddAddress("Jane Doe", "987 Main St.", "", "Beverly Hills", "CA", 90210); // Test Address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 upv.AddAddress("Ryan Leezer", "666 Spring St", "", "New York CIty", "NY", 37219); //Test Address 5 upv.AddAddress("Jessica Lewis", "100 7th St", "", "Tampa", "FL", 57611); //Test Address 6 upv.AddAddress("Mark Hunt", "123 11th St", "Apt. 2", "Phoenix", "AZ", 21399); //Test Address 7 upv.AddAddress("Mary Gates", "2838 W Jefferson St", "", "Atlanta", "GA", 18042); //Test Address 8 upv.AddLetter(upv.AddressAt(0), upv.AddressAt(1), 3.55M); //Letter upv.AddLetter(upv.AddressAt(2), upv.AddressAt(4), 4.20M); //Letter 2 upv.AddLetter(upv.AddressAt(3), upv.AddressAt(6), 5.35M); //Letter 3 }
private UserParcelView userParcelView; //The UserPacelView Instance Variable. //Pre-Condition: none. //Post-Condition: The Prog2Forms GUI is prepared and test data is added to // the addresses and parcel lists. public Prog2Form() { InitializeComponent(); userParcelView = new UserParcelView(); //initializes the UserParcelView instance //addresses test data userParcelView.AddAddress(" John Smith ", " 123 Any St. ", " Apt. 45 ", " Louisville ", " KY ", 40202); // Test Address 1 userParcelView.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90210); // Test Address 2 userParcelView.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 userParcelView.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 userParcelView.AddAddress("Nicholas Goodridge", "1234 1st Street", "Apt #207", "Louisville", "KY", 12345); //parcels test data userParcelView.AddLetter(userParcelView.AddressAt(1), userParcelView.AddressAt(2), 1.00M); userParcelView.AddLetter(userParcelView.AddressAt(0), userParcelView.AddressAt(3), 0.65M); userParcelView.AddLetter(userParcelView.AddressAt(4), userParcelView.AddressAt(1), 2.35M); }
private UserParcelView upv; //UserParcelView //Precondition: None //Postcondition: GUI form is created // Creates address form and letter form // if the user selects those options from // the menu. // Data collected from this form is sent to // the UserParcelView class to be created // into lists. public Prog2Form() { //Precondition: None //Postcondition: Form is created InitializeComponent(); //Creating an object of the UserParcelView upv = new UserParcelView(); //Test Data: Addresses upv.AddAddress(" John Smith ", " 123 Any St. ", " Apt. 45 ", " Louisville ", " KY ", 40202); // Test Address 1 upv.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90210); // Test Address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 upv.AddAddress("Charlotte Jones", "123 Maple St. ", "Clarksville", "IN", 47129); // Test Address 5 upv.AddAddress("Kayla Kay", "989 Chipp Avenue", "Apt. 2", "Salem", "IN", 52143); // Test Address 6 upv.AddAddress("Hunter Ansleigh", "554 Herrick Way", "Jeffersonville", "IN", 47130); // Test Address 7 upv.AddAddress("Mckenzie Caldwell", "2201 Morgan Avenue", "Charlestown", "KY", 42450); // Test Address 8 //Test Data: Letters upv.AddLetter(upv.AddressAt(0), upv.AddressAt(1), 3.95M); upv.AddLetter(upv.AddressAt(3), upv.AddressAt(2), 2.05M); //Test Data: GroundPackages upv.AddGroundPackage(upv.AddressAt(2), upv.AddressAt(3), 14, 10, 5, 12.5); upv.AddGroundPackage(upv.AddressAt(1), upv.AddressAt(5), 22, 15, 16, 28); //Test Data: NextDayAirPackages upv.AddNextDayAirPackage(upv.AddressAt(5), upv.AddressAt(0), 25, 15, 15, 85, 7.50M); upv.AddNextDayAirPackage(upv.AddressAt(1), upv.AddressAt(2), 50, 20, 15, 120, 9.75M); //Test Data: TwoDayAirPackages upv.AddTwoDayAirPackage(upv.AddressAt(3), upv.AddressAt(2), 46.5, 39.5, 28.0, 80.5, TwoDayAirPackage.Delivery.Saver); upv.AddTwoDayAirPackage(upv.AddressAt(7), upv.AddressAt(6), 20.75, 16.20, 20.50, 120.75, TwoDayAirPackage.Delivery.Early); }
public UserParcelView upv = new UserParcelView(); //creates a UserParcelView object public MainForm() { InitializeComponent(); //pre-stored address values for quick testing upv.AddAddress(" John Smith ", " 123 Any St. ", " Apt. 45", "Louisville ", " KY ", 40202); // Test Address 1 upv.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90210); // Test Address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 upv.AddAddress("Test name", "Test address_1", "Test address_2", "Test city", "Test state", 99999); //Test address 5 upv.AddAddress("Joe", "123 The Street", "wut", "NYC", "NY", 12345); //Test address 6 upv.AddAddress("Dr. Wright", "I dont know where you live", "Louisville", "KY", 40217); //Test address 7 upv.AddAddress("'Ol McDonald", "had a farm", " eee eye eee eye", "Farmville", "T E X A S", 5); //Test address 8 upv.AddLetter(upv.AddressAt(0), upv.AddressAt(2), 0.50M); // Test Letter 1 upv.AddLetter(upv.AddressAt(2), upv.AddressAt(2), 1.20M); // Test Letter 2 upv.AddLetter(upv.AddressAt(4), upv.AddressAt(0), 1.70M); // Test Letter 3 upv.AddGroundPackage(upv.AddressAt(4), upv.AddressAt(5), 5, 10, 1, 100); //Test Groundpackage 1 upv.AddGroundPackage(upv.AddressAt(0), upv.AddressAt(6), 10, 10, 5, 25); //Test Groundpackage 2 upv.AddNextDayAirPackage(upv.AddressAt(5), upv.AddressAt(6), 5, 10, 1, 100, 150); //Test Next Day Air Package Heavy upv.AddNextDayAirPackage(upv.AddressAt(5), upv.AddressAt(6), 5, 10, 100, 49.9, 150); //Test Next Day Air Package Large upv.AddNextDayAirPackage(upv.AddressAt(5), upv.AddressAt(5), 5, 10, 100, 50, 150); //Test Next Day Air Package Large & Heavy upv.AddTwoDayAirPackage(upv.AddressAt(7), upv.AddressAt(3), 5, 10, 1, 150, TwoDayAirPackage.Delivery.Saver); //Test Two Day Air Package that is a Saver upv.AddTwoDayAirPackage(upv.AddressAt(6), upv.AddressAt(2), 5, 10, 1, 75, TwoDayAirPackage.Delivery.Early); //Test Two Day Air Package that is a Early }
private UserParcelView upv; // The UserParcelView // Preconditon: None // Postconditon: Prog2 form is initialized public Prog2Form() { InitializeComponent(); upv = new UserParcelView(); // test data upv.AddAddress(" John Smith ", " 123 Any St. ", " Apt. 45 ", " Louisville ", " KY ", 40202); // Test Address 1 upv.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90210); // Test Address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 upv.AddAddress("John Doe", "111 Market St.", "Jeffersonville", "IN", 47130); // Test Address 5 upv.AddAddress("Jane Smith", "55 Hollywood Blvd.", "Apt. 9", "Los Angeles", "CA", 90212); // Test Address 6 upv.AddAddress("Captain Robert Crunch", "21 Cereal Rd.", "Room 987", "Bethesda", "MD", 20810); // Test Address 7 upv.AddAddress("Vlad Dracula", "6543 Vampire Way", "Apt. 1", "Bloodsucker City", "TN", 37210); // Test Address 8 upv.AddLetter(upv.AddressAt(0), upv.AddressAt(1), 5.00M); // Letter test object upv.AddLetter(upv.AddressAt(2), upv.AddressAt(3), 2.50M); // Letter test object upv.AddGroundPackage(upv.AddressAt(4), upv.AddressAt(5), 4.5, 5.0, 10, 25); //groundpackage test object upv.AddGroundPackage(upv.AddressAt(6), upv.AddressAt(7), 7, 5, 10, 30); // groundpackage test object upv.AddNextDayAirPackage(upv.AddressAt(6), upv.AddressAt(0), 10, 15, 8.5, 10, 20.50M); //NextDayAirPackage test object upv.AddNextDayAirPackage(upv.AddressAt(3), upv.AddressAt(7), 15, 18, 20, 45, 50.75M); //NextDayAirPackage test object upv.AddTwoDayAirPackage(upv.AddressAt(2), upv.AddressAt(7), 12, 14, 11, 34, TwoDayAirPackage.Delivery.Saver); //TwoDayAirPackage test object upv.AddTwoDayAirPackage(upv.AddressAt(1), upv.AddressAt(5), 10, 5, 19, 48, TwoDayAirPackage.Delivery.Early); //TwoDayAirPackage test objec }
private UserParcelView upv; //Will hold all addresses and parcels //Precondition: None //Postcondition: Program runs and initializes all addresses and parcels public Prog2Form() { InitializeComponent(); upv = new UserParcelView(); //Instantiate UserParcelView // Test Data - Magic Numbers OK upv.AddAddress(" John Smith ", " 123 Any St. ", " Apt. 45 ", " Louisville ", " KY ", 40202); // Test Address 1 upv.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90222); // Test Address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 upv.AddAddress("Patrick Warren", "8431 Easton Commons Dr", "Apt. B", "Louisville", "Ky", 40242); //Test Address 5 upv.AddAddress("Stan Lee", "9440 Santa Monica Blvd", "Suite 620", "Beveryly Hills", "CA", 90210); //Test Address 6 upv.AddAddress("Eric McDowell", "2940 Yorkshire Blvd", "Louisville", "Ky", 40220); upv.AddAddress("Harry Potter", "123 6th St.", "Melbourne", "FL", 32904); upv.AddLetter(upv.AddressAt(0), upv.AddressAt(1), 4.95M); // Letter test object upv.AddGroundPackage(upv.AddressAt(2), upv.AddressAt(3), 14, 10, 5, 14.5); // Ground test object upv.AddNextDayAirPackage(upv.AddressAt(0), upv.AddressAt(2), 25, 15, 15, // Next Day test object 90, 8.50M); upv.AddTwoDayAirPackage(upv.AddressAt(3), upv.AddressAt(0), 46.5, 39.5, 28.0, // Two Day test object 130, TwoDayAirPackage.Delivery.Saver); upv.AddLetter(upv.AddressAt(4), upv.AddressAt(5), 3.95M); // Letter test object upv.AddGroundPackage(upv.AddressAt(6), upv.AddressAt(7), 14, 10, 5, 12.5); // Ground test object upv.AddNextDayAirPackage(upv.AddressAt(4), upv.AddressAt(6), 25, 15, 15, // Next Day test object 100.5, 7.50M); upv.AddTwoDayAirPackage(upv.AddressAt(7), upv.AddressAt(4), 46.5, 39.5, 28.0, // Two Day test object 95, TwoDayAirPackage.Delivery.Saver); }
UserParcelView testa = new UserParcelView(); //UPV object //Precondition: None //Postcondition: The Prog2Form is initialized with test data public Prog2Form() { InitializeComponent(); testa.AddAddress("John Jacob", "112 Oakland Ave", "", "Louisville", "KY", 40204); testa.AddAddress("Jingle Hymersmith", "555 Rhinehard Ln", "Apt. 9", "Aville", "WV", 12345); testa.AddAddress("Aberdee Z", "12 Baxter", "Unit 100", "Aplace", "NY", 67895); testa.AddAddress("Aye Person", "Pirate Cove", "", "Dangertown", "CA", 55555); testa.AddAddress("Luke Elwalker", "Rebelscum St", "", "Dagoba", "VA", 22553); testa.AddAddress("Grown Man", "2234 Hisown Pl", "Apt. 9 3/4", "Avillage", "KY", 05551); testa.AddLetter(testa.AddressAt(0), testa.AddressAt(1), 12.95M); testa.AddLetter(testa.AddressAt(2), testa.AddressAt(3), 2.99M); testa.AddLetter(testa.AddressAt(4), testa.AddressAt(5), 55.98M); testa.AddGroundPackage(testa.AddressAt(2), testa.AddressAt(3), 12, 23, 12, 100); testa.AddNextDayAirPackage(testa.AddressAt(4), testa.AddressAt(2), 19, 23, 5, 23, 22.01M); }
// Precondition: Edit, Address menu item activated // Postcondition: Chosen address is updated according // to user's input private void editAddressToolStripMenuItem1_Click(object sender, EventArgs e) { ChooseAddressForm chooseAddressForm = new ChooseAddressForm(upv.AddressList); // The address dialog box form DialogResult chooseAddressResult = chooseAddressForm.ShowDialog(); // Show form as dialog and store result if (chooseAddressResult == DialogResult.OK) // Only select if OK { int addressAt = chooseAddressForm.ChooseAddressIndex; // Holds index for for the addressAt variable Address editAddress = upv.AddressAt(addressAt); // Holds address data AddressForm editAddressForm = new AddressForm(); // The address dialog box form editAddressForm.AddressName = editAddress.Name; editAddressForm.Address1 = editAddress.Address1; editAddressForm.Address2 = editAddress.Address2; editAddressForm.City = editAddress.City; editAddressForm.State = editAddress.State; editAddressForm.ZipText = editAddress.Zip.ToString("d5"); DialogResult editAddressResult = editAddressForm.ShowDialog(); // Show form as dialog and store result if (editAddressResult == DialogResult.OK) // Only edit if OK { upv.AddressAt(addressAt).Name = editAddressForm.AddressName; upv.AddressAt(addressAt).Address1 = editAddressForm.Address1; upv.AddressAt(addressAt).Address2 = editAddressForm.Address2; upv.AddressAt(addressAt).City = editAddressForm.City; upv.AddressAt(addressAt).State = editAddressForm.State; try { upv.AddressAt(addressAt).Zip = int.Parse(editAddressForm.ZipText); } catch (ArgumentOutOfRangeException) { // notify user if zip code is invalid MessageBox.Show("Enter valid zip code", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (ArgumentNullException) { // notify user if zip code is invalid MessageBox.Show("Enter a zip code", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (OverflowException) { // notify user if zip code is invalid MessageBox.Show("Enter valid zip code", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (FormatException) { // notify user if zip code is invalid MessageBox.Show("Enter valid zip code", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } editAddressForm.Dispose(); } chooseAddressForm.Dispose(); }
private UserParcelView upv; //UPV //Precondition: None //Postcondition: GUI prepared for display public Prog2Form() { InitializeComponent(); upv = new UserParcelView(); upv.AddAddress("Judy Cox", "2749 Duck Creek Road", "Palo Alto", "CA", 94306); //Test Address 1 upv.AddAddress("Rebecca Norris", "626 Kembery Drive", "Bucks", "AL", 36512); //Test Address 2 upv.AddAddress("Jerry Owen", "2147 Eagles Nest Drive", "Apt. 2", "Sacramento", "CA", 95814); //Test Address 3 upv.AddAddress("Francis Underwood", "1600 Pennsylvania Ave. NW", "Washington", "DC", 20500); //Test Address 4 upv.AddAddress("Shrimply Pibbles", "123 Galactic Federation Dr.", "Seattle", "WA", 98155); //Test Address 5 upv.AddAddress("Humany McHumanface", "745 Address Ave.", "Louisville", "KY", 40245); //Test Address 6 upv.AddAddress("Namey McNameface", "4923 Addressy McAddressface Way", "Glendale", "CA", 91204); //Test Address 7 upv.AddAddress("Jerry Seinfeld", "129 West 81st St.", "Apartment 5A", "New York", "NY", 10017); //Test Address 8 upv.AddLetter(upv.AddressAt(0), upv.AddressAt(2), 3.50M); //Test Letter 1 upv.AddLetter(upv.AddressAt(3), upv.AddressAt(4), 2.00M); //Test Letter 2 upv.AddGroundPackage(upv.AddressAt(5), upv.AddressAt(6), 10, 10, 10, 20); //Test GP 1 upv.AddGroundPackage(upv.AddressAt(7), upv.AddressAt(5), 100, 75, 25, 80); //Test GP 2 upv.AddNextDayAirPackage(upv.AddressAt(1), upv.AddressAt(5), 5, 5, 5, 15, 10.00M); //Test NDAP 1 upv.AddNextDayAirPackage(upv.AddressAt(2), upv.AddressAt(3), 2.5, 2.6, 2.7, 5, 5.00M); //Test NDAP 2 upv.AddTwoDayAirPackage(upv.AddressAt(4), upv.AddressAt(0), 10, 15, 20, 25, TwoDayAirPackage.Delivery.Saver); //Test TDAP 1 upv.AddTwoDayAirPackage(upv.AddressAt(6), upv.AddressAt(7), 30, 30, 30, 300, TwoDayAirPackage.Delivery.Early); //Test TDAP2 }
private UserParcelView _upvTest = new UserParcelView(); //Object that contains all test data and new data as program runs //Constructor //precondition: must have UPV object to store test data //postcondition: main form GUI is initialized public Prog2Form() { //Test Data: Addresses _upvTest.AddAddress("John Smith", "123 Any St.", "Apt. 45", "Louisville", "KY", 40202); // Test Address 1 _upvTest.AddAddress("Jane Doe", "987 Main St.", "", "Beverly Hills", "CA", 90210); // Test Address 2 _upvTest.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 _upvTest.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 _upvTest.AddAddress("James Haverstock", "10101 Linn Station Rd", "Suite 200", "Louisville", "KY", 40223); // Test Address 5 _upvTest.AddAddress("Paul Jacob", "4107 SpyGlass Ct", "", "Louisville", "KY", 40229); // Test Address 6 _upvTest.AddAddress("Laura Payne", "320 E Esplenade Ave", "", "Louisville", "KY", 40213); // Test Address 7 _upvTest.AddAddress("Geraldine Spicer", "8601 Timberhallow Ct", "", "Louisville", "KY", 40219); // Test Address 8 //Test Date: Parcels _upvTest.AddLetter(_upvTest.AddressAt(0), _upvTest.AddressAt(2), 1.50M); // Test Letter 1 _upvTest.AddLetter(_upvTest.AddressAt(2), _upvTest.AddressAt(4), 1.25M); // Test Letter 2 _upvTest.AddLetter(_upvTest.AddressAt(4), _upvTest.AddressAt(0), 1.75M); // Test Letter 3 _upvTest.AddGroundPackage(_upvTest.AddressAt(5), _upvTest.AddressAt(6), 3, 6, 9, 12); // Test GroundPackage 1 _upvTest.AddGroundPackage(_upvTest.AddressAt(4), _upvTest.AddressAt(7), 12, 9, 6, 3); // Test GroundPackage 2 _upvTest.AddGroundPackage(_upvTest.AddressAt(3), _upvTest.AddressAt(7), 6, 7, 9, 100); // Test GroundPackage 3 _upvTest.AddNextDayAirPackage(_upvTest.AddressAt(4), _upvTest.AddressAt(7), 500, 12, 12, 12, 12); // Test NextDayAirPackage 1 _upvTest.AddNextDayAirPackage(_upvTest.AddressAt(7), _upvTest.AddressAt(2), 20, 7, 7, 7, 70); // Test NextDayAirPackage 2 _upvTest.AddNextDayAirPackage(_upvTest.AddressAt(1), _upvTest.AddressAt(4), 5, 1, 2, 3, 4); // Test NextDayAirPackage 3 _upvTest.AddTwoDayAirPackage(_upvTest.AddressAt(3), _upvTest.AddressAt(6), 9, 9, 9, 200, TwoDayAirPackage.Delivery.Saver); //Test TwoDayAirPackage 1 _upvTest.AddTwoDayAirPackage(_upvTest.AddressAt(6), _upvTest.AddressAt(1), 10, 20, 30, 40, TwoDayAirPackage.Delivery.Early); //Test TwoDayAirPackage 2 _upvTest.AddTwoDayAirPackage(_upvTest.AddressAt(1), _upvTest.AddressAt(6), 100, 90, 80, 76, TwoDayAirPackage.Delivery.Saver); //Test TwoDayAirPackage 3 InitializeComponent(); }
string NL = Environment.NewLine; // Stores NewLine shortcut // Precondition: None // Postcondition: Initializes program and all test objects public Prog2Form() { InitializeComponent(); upv = new UserParcelView(); // creates eight test Address objects upv.AddAddress("Rrose Selavy", "5454 Dada Ave.", "Apt. 66", "New York", "Ny", 10019); upv.AddAddress("Leonora Carrington", "9632 Hyena Blvd.", "Ojai", "CA", 90322); upv.AddAddress("Meret Oppenheim", "54 Teacup Ln.", "Apt. 3", "Chicago", "IL", 34998); upv.AddAddress("Joan Miro", "9021 Sculpture Dr.", "Portland", "OR", 98069); upv.AddAddress("Hugo Ball", "901 Century Ct.", "Miami", "FL", 20001); upv.AddAddress("Leonor Fini", "306 Lake Pl.", "Unit 4C", "Denver", "CO", 76663); upv.AddAddress("Tristan Tzara", "5050 Paris St.", "Omaha", "NE", 55091); upv.AddAddress("Marcel Duchamp", "669 R. Mutt NE", "Woodinville", "WA", 99886); // creates eight test Parcel objects upv.AddLetter(upv.AddressAt(0), upv.AddressAt(1), 3.75M); upv.AddLetter(upv.AddressAt(3), upv.AddressAt(4), 2.25M); upv.AddGroundPackage(upv.AddressAt(5), upv.AddressAt(6), 10, 5.5, 2, 2); upv.AddGroundPackage(upv.AddressAt(6), upv.AddressAt(7), 7, 3, 1.5, 17); upv.AddNextDayAirPackage(upv.AddressAt(0), upv.AddressAt(7), 10, 12, 6.5, 9, 12.50M); upv.AddNextDayAirPackage(upv.AddressAt(1), upv.AddressAt(6), 30, 24, 12, 83, 25.0M); upv.AddTwoDayAirPackage(upv.AddressAt(2), upv.AddressAt(5), 24, 13.5, 3, 77, TwoDayAirPackage.Delivery.Early); upv.AddTwoDayAirPackage(upv.AddressAt(3), upv.AddressAt(4), 36, 36, 36, 45, TwoDayAirPackage.Delivery.Saver); }
/* * Preconditions: None * Postcondition: Form is initialized. */ public Prog2Form() { InitializeComponent(); upv.AddAddress("Helen C. Bice", "1163 Thompson Drive", "El Sobrante", "CA", 94803); upv.AddAddress("Teresa T. Johnson", "3542 Farland Street", "Apt 101", "Westborough", "MA", 01581); upv.AddAddress("Troy H. Thomas", "1299 Saints Alley", "Plant City", "FL", 33564); upv.AddAddress("Susan K. McCrady", "3118 Chenoweth Drive", "Apt B3", "Clarksville", "TN", 37040); upv.AddAddress("Nicholle C. Warren", "2187 Leo Street", "Pittsburgh", "PA", 15203); upv.AddAddress("Vanessa P. Burgos", "373 Wayback Lane", "New York", "NY", 10013); upv.AddAddress("Amy T. Hight", "4254 Valley Drive", "North Wales", "PA", 19454); upv.AddAddress("Lauren A. Proffitt", "2269 Boggess Street", "Apt 101", "Wichita Falls", "TX", 76301); upv.AddGroundPackage(upv.AddressAt(0), upv.AddressAt(1), 5, 5, 6, 1); upv.AddGroundPackage(upv.AddressAt(0), upv.AddressAt(1), 30, 42, 18, 60); upv.AddNextDayAirPackage(upv.AddressAt(0), upv.AddressAt(3), 40, 20, 60, 74, 10M); upv.AddNextDayAirPackage(upv.AddressAt(4), upv.AddressAt(2), 10, 13, 13, 100, 50M); upv.AddTwoDayAirPackage(upv.AddressAt(2), upv.AddressAt(1), 20, 25, 50, 75, TwoDayAirPackage.Delivery.Early); upv.AddTwoDayAirPackage(upv.AddressAt(2), upv.AddressAt(3), 40, 40, 20, 76, TwoDayAirPackage.Delivery.Saver); upv.AddLetter(upv.AddressAt(2), upv.AddressAt(0), 0.46M); upv.AddLetter(upv.AddressAt(4), upv.AddressAt(6), 0.77M); upv.AddGroundPackage(upv.AddressAt(7), upv.AddressAt(5), 30, 23, 98, 12); upv.AddNextDayAirPackage(upv.AddressAt(3), upv.AddressAt(6), 22, 32, 18, 32, 15M); }
//precondition: none. //postcondition: preloads test information into program. private void mainForm_Load(object sender, EventArgs e) { formObject.AddAddress("John Smith", "123 Any St.", "Apt. 45", "Louisville", "KY", 40202); // Test Address 1 formObject.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90210); // Test Address 2 formObject.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 formObject.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 formObject.AddAddress("Tim Jones", "865 Good Music Drive", "Nashville", "TN", 37027); // Test Address 5 formObject.AddAddress("Jonny Banana", "942 Private Beach Drive", "Clearwater", "FL", 33755); // Test Address 6 formObject.AddAddress("Juan Martinez", "15946 Big Hat Lane", "Apt. 5B", "Austin", "TX", 73344); // Test Address 7 formObject.AddAddress("Frank Chowder", "321 Too Cold Way", "Manchester", "NH", 03107); // Test Address 8 formObject.AddLetter(formObject.AddressAt(0), formObject.AddressAt(5), 3.95M); //test Letter parcel formObject.AddLetter(formObject.AddressAt(2), formObject.AddressAt(7), 5.25M); //test Letter parcel formObject.AddLetter(formObject.AddressAt(4), formObject.AddressAt(1), 0.55M); //test Letter parcel formObject.AddGroundPackage(formObject.AddressAt(3), formObject.AddressAt(7), 23, 12, 10, 45); //test groundPackag parcel formObject.AddGroundPackage(formObject.AddressAt(6), formObject.AddressAt(1), 5, 25, 30, 15); //test groundPackag parcel formObject.AddGroundPackage(formObject.AddressAt(5), formObject.AddressAt(5), 15, 35, 40, 75); //test groundPackag parcel }
public UserParcelView upv; //The UserParcelView // Precondition: None // Postcondition: The form's GUI is prepared for display. public Prog2Form() { InitializeComponent(); upv = new UserParcelView(); //Test Data upv.AddAddress("John Smith", "123 Any St.", "Apt. 45", "Louisville", "KY", 40202); // Test Address 1 upv.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90210); // Test Address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 upv.AddAddress("Billy Walsh", "123 Hollywood Lane", "Pasadena", "CA", 10100); // Test Address 5 upv.AddAddress("Vincent Chase", "456 Rich Road", "Los Angeles", "CA", 75432); // Test Address 6 upv.AddAddress("Eric Murphy", "111 Short Street", "Benton", "KY", 42025); // Test Address 7 upv.AddAddress("Ari Gold", "414 Fairview Street", "Apt. 12", "Paducah", "KY", 83325); // Test Address 8 // Letter test objects upv.AddLetter(upv.AddressAt(0), upv.AddressAt(1), 3.95M); upv.AddLetter(upv.AddressAt(2), upv.AddressAt(3), 4.25M); // Ground Package test objects upv.AddGroundPackage(upv.AddressAt(4), upv.AddressAt(5), 14, 10, 5, 12.5); upv.AddGroundPackage(upv.AddressAt(6), upv.AddressAt(7), 20, 7, 4, 20); // Next Day Air Package test objects upv.AddNextDayAirPackage(upv.AddressAt(0), upv.AddressAt(2), 25, 15, 15, 85, 7.50M); upv.AddNextDayAirPackage(upv.AddressAt(2), upv.AddressAt(4), 11, 22, 9, 70, 7.38M); upv.AddNextDayAirPackage(upv.AddressAt(1), upv.AddressAt(6), 10.5, 20, 11, 75, 7.38M); // Two Day Air Package test objects upv.AddTwoDayAirPackage(upv.AddressAt(6), upv.AddressAt(3), 46.5, 39.5, 28.0, 80.5, TwoDayAirPackage.Delivery.Saver); upv.AddTwoDayAirPackage(upv.AddressAt(7), upv.AddressAt(5), 46.5, 39.5, 28.0, 80.5, TwoDayAirPackage.Delivery.Early); upv.AddTwoDayAirPackage(upv.AddressAt(1), upv.AddressAt(0), 46.5, 39.5, 28.0, 80.5, TwoDayAirPackage.Delivery.Saver); }
public Prog2Form() { InitializeComponent(); upv = new UserParcelView(); // Test Data - Magic Numbers OK upv.AddAddress(" John Smith ", " 123 Any St. ", " Apt. 45 ", " Louisville ", " KY ", 40202); // Test Address 1 upv.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90210); // Test Address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 upv.AddAddress("Lester Joy", "156 Hunters Place", "Benton", "KY", 40114); // Test Address 5 upv.AddAddress("Ben Polly", "67 Young Street", "Danville", "CA", 92108); // Test Address 6 upv.AddAddress("Hillary Mont", "791 Prog Ave", "Polar", "AL", 56123); // Test Address 7 upv.AddAddress("Monica Key", "091 Mice Ave", "Welro", "MI", 40981); // Test Address 8 upv.AddLetter(upv.AddressAt(0), upv.AddressAt(1), 3.95M); // Letter test object upv.AddLetter(upv.AddressAt(3), upv.AddressAt(5), 8.67M); upv.AddGroundPackage(upv.AddressAt(6), upv.AddressAt(7), 14, 10, 5, 12.5); // Ground test object upv.AddGroundPackage(upv.AddressAt(2), upv.AddressAt(4), 65, 43, 87, 115); upv.AddNextDayAirPackage(upv.AddressAt(3), upv.AddressAt(1), 25, 15, 15, // Next Day test object 85, 7.50M); upv.AddNextDayAirPackage(upv.AddressAt(7), upv.AddressAt(0), 34, 23, 56, 180, 9.80M); upv.AddTwoDayAirPackage(upv.AddressAt(2), upv.AddressAt(6), 46.5, 39.5, 28.0, // Two Day test object 300, TwoDayAirPackage.Delivery.Saver); upv.AddTwoDayAirPackage(upv.AddressAt(4), upv.AddressAt(5), 40.5, 45.3, 82.5, 400, TwoDayAirPackage.Delivery.Early); }
private UserParcelView upv; // Declare upv variable to be used on shipping public Prog2Form() { InitializeComponent(); upv = new UserParcelView(); // upv assigned as userparcelview method upv.AddAddress(" John Smith ", " 123 Any St. ", " Apt. 45 ", " Louisville ", " KY ", 40202); // Test Address 1 upv.AddAddress("Jane Doe", "987 Main St.", "Beverly Hills", "CA", 90210); // Test Address 2 upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); // Test Address 3 upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); // Test Address 4 upv.AddAddress("John Doe", "111 Market St.", "Jeffersonville", "IN", 47130); // Test Address 5 upv.AddAddress("Jane Smith", "55 Hollywood Blvd.", "Apt. 9", "Los Angeles", "CA", 90212); // Test Address 6 upv.AddAddress("Captain Robert Crunch", "21 Cereal Rd.", "Room 987", "Bethesda", "MD", 20810); // Test Address 7 upv.AddAddress("Vlad Dracula", "6543 Vampire Way", "Apt. 1", "Bloodsucker City", "TN", 37210); // Test Address 8 upv.AddLetter(upv.AddressAt(0), upv.AddressAt(1), 3.95M); // Add letter using upv upv.AddLetter(upv.AddressAt(2), upv.AddressAt(3), 4.25M); // Add letter using upv upv.AddGroundPackage(upv.AddressAt(4), upv.AddressAt(5), 14, 10, 5, 12.5); // Add groundpackage using upv upv.AddGroundPackage(upv.AddressAt(6), upv.AddressAt(7), 8.5, 9.5, 6.5, 2.5); // Add groundpackage using upv upv.AddNextDayAirPackage(upv.AddressAt(0), upv.AddressAt(2), 25, 15, 15, 85, 7.50M); // Add nextdayairpackage using upv upv.AddNextDayAirPackage(upv.AddressAt(2), upv.AddressAt(4), 9.5, 6.0, 5.5, 5.25, 5.25M); // Add nextdayairpackage using upv upv.AddNextDayAirPackage(upv.AddressAt(1), upv.AddressAt(6), 10.5, 6.5, 9.5, 15.5, 5.00M); // Add nextdayairpackage using upv upv.AddTwoDayAirPackage(upv.AddressAt(4), upv.AddressAt(6), 46.5, 39.5, 28.0, 80.5, TwoDayAirPackage.Delivery.Saver); // Add twodayairpackage using upv upv.AddTwoDayAirPackage(upv.AddressAt(7), upv.AddressAt(0), 15.0, 9.5, 6.5, 75.5, TwoDayAirPackage.Delivery.Early); // Add twodayairpackage using upv upv.AddTwoDayAirPackage(upv.AddressAt(5), upv.AddressAt(3), 12.0, 12.0, 6.0, 5.5, TwoDayAirPackage.Delivery.Saver); // Add twodayairpackage using upv }