public UserParcelView upvController = new UserParcelView(); // The UserParcelView object to be used throughout the program. // Pre-Condition: None // Post-Condition: A new Prog2Form object is created. // Three test addresses are created. Three test letters are created. public Prog2Form() { InitializeComponent(); upvController.AddAddress("test address 1", "123 random st.", "somewhere", "KS", 12345); upvController.AddAddress("test address 2", "456 this ave.", "polis", "KY", 67891); upvController.AddAddress("test address 3", "789 park pl.", "acity", "NY", 49832); upvController.AddLetter(upvController.AddressList[0], upvController.AddressList[1], 3.12M); upvController.AddLetter(upvController.AddressList[2], upvController.AddressList[1], 1.57M); upvController.AddLetter(upvController.AddressList[2], upvController.AddressList[0], 2.23M); }
/* * 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); }
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 }
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 }
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); }
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 }
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 }
//Precondition: none //Postcondition: The main form has been created and the test addresses and letters are added. public Prog2Form() { InitializeComponent(); //Adding addresses to the UPV object. upvObject.AddAddress("Homer Simpson", "742 Evergreen Terrace", "Springfield", "OR", 97403); upvObject.AddAddress("Batman", "Bat Cave", "Gotham", "NY", 10001); upvObject.AddAddress("Harry Potter", "4 Privet Drive", "Little Whingeing", "HP", 62442); //Adding letters to the UPV object. upvObject.AddLetter(a1, a3, 10); upvObject.AddLetter(a2, a1, 15); upvObject.AddLetter(a3, a2, 20); }
//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 }
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 }
//Precondition: Address menu item is clicked. //Postcondition: Input from address form is stored and sent to UPV. private void addressToolStripMenuItem_Click(object sender, EventArgs e) { AddressForm AddressForm = new AddressForm(); DialogResult result; string name; //Variable to hold name string address1; //Variable to hold address line 1 string address2; //Variable to hold address line 2 string city; //Variable to hold city string state; //Variable to hold state int zip; //Variable to hold zip result = AddressForm.ShowDialog(); //Show Address form on top of main form if (result == DialogResult.OK) //If the dialog result is okay { name = AddressForm.AddressName; address1 = AddressForm.AddressLine1; address2 = AddressForm.AddressLine2; city = AddressForm.AddressCity; state = AddressForm.AddressState; zip = int.Parse(AddressForm.AddressZip); upv.AddAddress(name, address1, address2, city, state, zip); //Use add address method to add address input to UPV. } }
//Precondition: User clicks "address" menu item //Postcondition: Address form is created and shown // as a dialog box private void addressToolStripMenuItem_Click(object sender, EventArgs e) { Prog2.AddressForm addressForm = new Prog2.AddressForm(); // creates address form DialogResult result; // Result from dialog - OK/Cancel? string name; // User's input for name (gather from dialog box) string address1; // User's input for address 1 (gather from dialog box) string address2; // User's input for address 2 (gather from dialog box) string city; // User's input for city (gather from dialog box) string state; // User's input for state (gather from dialog box) int zip; // User's input for zip (gather from dialog box) result = addressForm.ShowDialog(); // Show dialog box form - modal, waits for OK/Cancel // Even after user dismisses, the form still exists // and can be interacted with using methods/properties //if the user clicks the OK button, the data will be input if (result == DialogResult.OK) { zip = int.Parse(addressForm.ZipInputValue); name = addressForm.NameInputValue; address1 = addressForm.Address1InputValue; address2 = addressForm.Address2InputValue; city = addressForm.CityInputValue; state = addressForm.StateInputValue; upv.AddAddress(name, address1, address2, city, state, zip); //adds the address input into the upv object } }
//Click event for the Add Address menu option protected void addressMenuItem_Click(object sender, EventArgs e) { AddressForm addressForm = new AddressForm(); // Creates a new instance of the AddressForm DialogResult result; // Holds result of dialog box result = addressForm.ShowDialog(); // Sets result = what was input // Holds the various information entered on AddressForm string addressName; string address1; string address2; string city; string state; int zip; if (result == DialogResult.OK) // If the user clicks ok on address form, info is entered and stored in upv { addressName = addressForm.AddressName; address1 = addressForm.Address1; address2 = addressForm.Address2; city = addressForm.City; state = addressForm.State; zip = addressForm.Zip; upv.AddAddress(addressName, address1, address2, city, state, zip); } }
// Precondition: The Insert >> Address menu item has been selected // Postcondition: A dialog box prompts the user for new Address information. // If the user submits, a new Address object is created. private void addressToolStripMenuItem_Click(object sender, EventArgs e) { AddAddressForm addAddress = new AddAddressForm(); // Calls Add Address Form DialogResult result = addAddress.ShowDialog(); // Result from dialog - OK/Cancel? if (result == DialogResult.OK) // Address is created if user selects OK from dialog box { upv.AddAddress(addAddress.NameInput, addAddress.Address1Input, addAddress.Address2Input, addAddress.CityInput, addAddress.StateInput, addAddress.ZipInput); } }
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); }
//Precondition: The address item on the insert menu has been clicked. //Postcondition: A dialog box has been displayed requesting address info. // If sumitted, an address object is stored in the Address list. private void addressToolStripMenuItem_Click(object sender, EventArgs e) { Address_Form addressForm = new Address_Form(); //Address dialog box form DialogResult result; //Result from dialog box result = addressForm.ShowDialog(); //Show dialog box form if (result == DialogResult.OK) //Update if user clicks OK form dialog box { upv.AddAddress(addressForm.InputName, addressForm.InputAddress, addressForm.InputAddress2, addressForm.InputCity, addressForm.InputState, addressForm.InputZip); } }
//Pre-Condition:The "Address" menu item is clicked //Post-Condition: The Address form is displayed as a dialog box // and if the OK button was clicked,the contents // are used to create a new address and added to addresses private void addressToolStripMenuItem_Click(object sender, EventArgs e) { AddressForm addressForm = new AddressForm(); //The Address form instnace is created DialogResult result; //variable to hold the result of the dialog result = addressForm.ShowDialog(); if (result == DialogResult.OK) { userParcelView.AddAddress(addressForm.NameBox, addressForm.AddressBox1, addressForm.AddressBox2, addressForm.CityBox, addressForm.StateCombo, int.Parse(addressForm.ZipBox)); } }
//Precondition: None //Postcondition: Shows form for and creates address private void addressToolStripMenuItem_Click(object sender, EventArgs e) { AddressForm afrm = new AddressForm(); DialogResult result = afrm.ShowDialog(); //Shows address dialog box if (result == DialogResult.OK) { upv.AddAddress(afrm.NameValue, afrm.AddressOne, afrm.AddressTwo, afrm.City, afrm.StateIndex, afrm.Zip); } afrm.Dispose(); //Resources are released }
//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 }
//Precondition: None //Postcondition:takes info added in the Address form and uses it to create a new // address object private void addressToolStripMenuItem_Click(object sender, EventArgs e) { AddressForm addressForm = new AddressForm(); //adds a new address form object DialogResult result; result = addressForm.ShowDialog(); // shows the form as a modal dialog box if (result == DialogResult.OK) //if all entered address info is valid { // adds the new address object to the list upv.AddAddress(addressForm.NameValue, addressForm.Address, addressForm.Address2, addressForm.City, addressForm.State, Convert.ToInt32(addressForm.Zip)); } }
// Precondition: addressToolStripMenuItem has been clicked // Postcondition: AddressForm has appeared private void addressToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result; Prog2.AddressForm addressObject = new Prog2.AddressForm(); result = addressObject.ShowDialog(); int zip; if (result == DialogResult.OK) { zip = int.Parse(addressObject.ZipValue); upv.AddAddress(addressObject.NameValue, addressObject.AddressValue, addressObject.CityValue, addressObject.StateValue, zip); } }
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); }
// Precondition: Button must be clicked // postcondition: the address form will be opened private void addressToolStripMenuItem_Click(object sender, EventArgs e) { AddressForm addressForm = new AddressForm(); DialogResult addressResult; addressResult = addressForm.ShowDialog(); if (addressResult == DialogResult.OK) { int zip; int.TryParse(addressForm.zipText, out zip); upv.AddAddress(addressForm.nameText, addressForm.address1Text, addressForm.address2Text, addressForm.cityText, addressForm.stateText, zip); } }
// Precondition: Insert, Address menu item activated // Postcondition: The Address dialog box is displayed. If data entered // are OK, an Address is created and added to the list // of addresses private void addressToolStripMenuItem_Click(object sender, EventArgs e) { AddressForm addressForm = new AddressForm(); // The address dialog box form DialogResult result = addressForm.ShowDialog(); // Show form as dialog and store result int zip; // Address zip code if (result == DialogResult.OK) // Only add if OK { if (int.TryParse(addressForm.ZipText, out zip)) { upv.AddAddress(addressForm.AddressName, addressForm.Address1, addressForm.Address2, addressForm.City, addressForm.State, zip); // Use form's properties to create address } else // This should never happen if form validation works! { MessageBox.Show("Problem with Address Validation!", "Validation Error"); } } addressForm.Dispose(); // Best practice for dialog boxes // Alternatively, use with using clause as in Ch. 17 }
// Precondition: None // Postcondition: Helper method to add test addresses to the upv private void AddAddresses() { // Add test data to upv list upv.AddAddress("John Smith", "123 Any St.", "Apt. 45", "Louisville", "KY", 40202); upv.AddAddress("Jane Doe", "987 Main St.", "", "Beverly Hills", "CA", 90210); upv.AddAddress("James Kirk", "654 Roddenberry Way", "Suite 321", "El Paso", "TX", 79901); upv.AddAddress("John Crichton", "678 Pau Place", "Apt. 7", "Portland", "ME", 04101); upv.AddAddress("Frank Miller", "5503 Hames Trace", "Apt 466", "Louisville", "KY", 40215); upv.AddAddress("William Hagopian", "346 S Howard St", "PO Box 12", "Atlanta", "GA", 30317); upv.AddAddress("Judy Faust", "3983 Explorer Rd", "", "Wheatfield", "IN", 46392); upv.AddAddress("Desirae Thompson", "2009 Joe Lane", "", "Kearney", "MO", 64048); }
//event handler for clicking of add address menu item //pre:buttomn clicked //post: launch form for creating new address private void addressToolStripMenuItem_Click(object sender, EventArgs e) { //create an instance of the form NewAddressForm inputForm = new NewAddressForm(); //show the form as a dialogue box inputForm.ShowDialog(); //if the dialogue is returned as successful if (inputForm.DialogResult == DialogResult.OK) { //checks if 2nd string was a valid value, if so has two address lines if (String.IsNullOrWhiteSpace(inputForm.AddressLineTwo)) { currentView.AddAddress(inputForm.AddressName, inputForm.AddressLineOne, inputForm.City, inputForm.State, inputForm.Zip); } //otherwise defaults to 1 address line else { currentView.AddAddress(inputForm.AddressName, inputForm.AddressLineOne, inputForm.AddressLineTwo, inputForm.City, inputForm.State, inputForm.Zip); } } }
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); }
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); }
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(); }
//Precondition: click //Postcondition: Show Address Form, Add address to upv AddressList public void addressToolStripMenuItem_Click(object sender, EventArgs e) { AddressForm AF = new AddressForm(); //create an AddressForm object DialogResult result; //holds result of the AddressForm button (OK/Cancel) result = AF.ShowDialog(); //Shows the form as a modal dialog box if (result == DialogResult.OK && AF.ValidateChildren()) //if Result is OK, then Add an Address to the UserParcelView AddressList { //Precondition: ValidateChildren() must return true //Postcondition: Add Address to UserParcelView Address list upv.AddAddress(AF.NameValue, AF.AddressValue, AF.AddressValue1, AF.CityValue, AF.StateValue, AF.ZipValue); } else if (result == DialogResult.Cancel) //Dispose of resources if result == cancel { AF.Dispose(); } }