예제 #1
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                                     "Louisville", "KY", 40202);    // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                                     "Beverly Hills", "CA", 90210); // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);       // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);      // Test Address 4
            Address a5 = new Address("Tyler Durden", "537 Paper Street", "",
                                     "Bradford", "DE", 19808);      // Test Address 5
            Address a6 = new Address("Robb Stark", "318 Snow Street", "",
                                     "Winterfell", "AK", 99502);    // Test Address 6
            Address a7 = new Address("Sherlock Holmes", "221 Baker Street", "Apt B",
                                     "Boston", "MA", 02201);        // Test Address 7


            Letter            l1    = new Letter(a1, a3, 1.50M);                                                     // Test Letter 1
            Letter            l2    = new Letter(a2, a4, 1.25M);                                                     // Test Letter 2
            Letter            l3    = new Letter(a4, a1, 1.75M);                                                     // Test Letter 3
            GroundPackage     gp1   = new GroundPackage(a4, a5, 20, 30, 40, 25);                                     // Test Ground Package 1
            GroundPackage     gp2   = new GroundPackage(a6, a7, 50, 50, 50, 50);                                     // Test Ground Package 2
            GroundPackage     gp3   = new GroundPackage(a4, a6, 10, 15, 10, 80);                                     // Test Ground Package 3
            NextDayAirPackage ndap1 = new NextDayAirPackage(a1, a5, 20, 25, 27, 30, 5);                              // Test Next Day Air Package 1
            NextDayAirPackage ndap2 = new NextDayAirPackage(a2, a6, 30, 40, 50, 25, 10);                             // Test Next Day Air Package 2
            NextDayAirPackage ndap3 = new NextDayAirPackage(a3, a4, 10, 10, 15, 85, 12);                             // Test Next Day Air Package 3
            TwoDayAirPackage  tdap1 = new TwoDayAirPackage(a7, a2, 30, 30, 30, 30, TwoDayAirPackage.Delivery.Saver); // Test Two Day Air Package 1
            TwoDayAirPackage  tdap2 = new TwoDayAirPackage(a3, a2, 43, 29, 32, 45, TwoDayAirPackage.Delivery.Early); // Test Two Day Air Package 2

            List <Parcel> parcels = new List <Parcel>();                                                             // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);
            parcels.Add(gp1);
            parcels.Add(gp2);
            parcels.Add(gp3);
            parcels.Add(ndap1);
            parcels.Add(ndap2);
            parcels.Add(ndap3);
            parcels.Add(tdap1);
            parcels.Add(tdap2);


            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }
            Console.ReadLine();
        }
예제 #2
0
파일: Program.cs 프로젝트: ptwarr44/CIS200
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("  John Smith  ", "   123 Any St.   ", "  Apt. 45 ",
                                     "  Louisville   ", "  KY   ", 40202); // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.",
                                     "Beverly Hills", "CA", 90210);        // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);              // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);             // Test Address 4


            Letter l1 = new Letter(a1, a3, 0.50M); // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.20M); // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.70M); // Test Letter 3


            //Program 1A Test Data
            GroundPackage     gp1   = new GroundPackage(a1, a3, 3, 5, 6.9, 7);
            NextDayAirPackage ndap1 = new NextDayAirPackage(a2, a4, 100, 40, 40, 40, 5);
            NextDayAirPackage ndap2 = new NextDayAirPackage(a3, a1, 40, 40.6, 40, 75, 20);
            TwoDayAirPackage  tdap1 = new TwoDayAirPackage(a3, a4, 40, 40, 40, 40, TwoDayAirPackage.Delivery.Saver);
            //Same as tdap1 except it will be Early.
            TwoDayAirPackage tdap2 = new TwoDayAirPackage(a3, a4, 40, 40, 40, 40, TwoDayAirPackage.Delivery.Early);

            List <Parcel> parcels = new List <Parcel>(); // Test list of parcels

            Parcel[] parcel = new Parcel[5] {
                gp1, ndap1, ndap2, tdap1, tdap2
            };
            foreach (var p in parcel)
            {
                Console.WriteLine($"Parcel: {p.ToString()}");
                Console.WriteLine("--------------------");
            }


            // Add test data to list
            //parcels.Add(l1);
            //parcels.Add(l2);
            //parcels.Add(l3);
            //parcels.Add(gp1);
            //parcels.Add(ndap1);
            //parcels.Add(ndap2);
            //parcels.Add(tdap1);
            //parcels.Add(tdap2);

            //// Display data
            //Console.WriteLine("Program 0 - List of Parcels\n");

            //foreach (Parcel p in parcels)
            //{
            //    Console.WriteLine(p);
            //    Console.WriteLine("--------------------");
            //}
        }
예제 #3
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                                     "Louisville", "KY", 40202);    // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                                     "Beverly Hills", "CA", 90210); // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);       // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);      // Test Address 4

            Letter l1 = new Letter(a1, a3, 1.50M);                  // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.25M);                  // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.75M);                  // Test Letter 3


            GroundPackage     gP1  = new GroundPackage(a1, a2, 3, 4, 4, 6);                                           // Test GroundPackage
            NextDayAirPackage nDA  = new NextDayAirPackage(a3, a1, 59, 22, 18, 100, 30m);                             // Test NextDayAirPackage
            NextDayAirPackage nDA2 = new NextDayAirPackage(a3, a1, 60, 24, 16, 100, 30m);                             // Test NextDayAirPackage2
            TwoDayAirPackage  tDA  = new TwoDayAirPackage(a4, a1, 80, 30, 20, 110, TwoDayAirPackage.Delivery.Early);  // Test TwoDayAirPackage
            TwoDayAirPackage  tDA2 = new TwoDayAirPackage(a4, a2, 100, 50, 14, 120, TwoDayAirPackage.Delivery.Saver); // Test TwoDayAirPackage2

            List <Package> packages = new List <Package>();                                                           // Test list of packages

            // Add test package data to the list
            packages.Add(gP1);
            packages.Add(nDA);
            packages.Add(nDA2);
            packages.Add(tDA);
            packages.Add(tDA2);
            //Display each package object in the list
            foreach (Package pk in packages)
            {
                Console.WriteLine(pk);
                Console.WriteLine("--------------------");
            }
            List <Parcel> parcels = new List <Parcel>();   // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }
        }
예제 #4
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("  John Smith  ", "   123 Any St.   ", "  Apt. 45 ",
                                     "  Louisville   ", "  KY   ", 40202); // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.",
                                     "Beverly Hills", "CA", 90210);        // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);              // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);             // Test Address 4

            Letter l1 = new Letter(a1, a3, 0.50M);                         // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.20M);                         // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.70M);                         // Test Letter 3

            List <Parcel> parcels = new List <Parcel>();                   // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }

            //Testing Output for Program 1A
            Console.WriteLine("---------- 1A Testing ----------");

            List <Parcel> progAParcels = new List <Parcel>();

            TwoDayAirPackage airCrate = new TwoDayAirPackage(a1, a2, 12, 5, 3, 4, TwoDayAirPackage.Delivery.Early);

            progAParcels.Add(airCrate);
            NextDayAirPackage nextDayAirCrate = new NextDayAirPackage(a3, a1, 23, 14, 10, 13, 10);

            progAParcels.Add(nextDayAirCrate);
            GroundPackage groundCrate = new GroundPackage(a2, a1, 12, 5, 4, 100);

            progAParcels.Add(groundCrate);

            foreach (Parcel e in progAParcels)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("--------------------");
            }
        }
예제 #5
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                                     "Louisville", "KY", 40202);    // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                                     "Beverly Hills", "CA", 90210); // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);       // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);      // Test Address 4

            Letter l1 = new Letter(a1, a3, 1.50M);                  // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.25M);                  // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.75M);                  // Test Letter 3

            List <Parcel> parcels = new List <Parcel>();            // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }

            //TESTING BEGINS HERE
            Console.WriteLine("-------------GroundPackage----------------");
            GroundPackage test = new GroundPackage(1, 1, 1, 1, a1, a2);

            Console.WriteLine(test);

            Console.WriteLine("-------------NextDayAirPackage-----------------");
            NextDayAirPackage test2 = new NextDayAirPackage(0, 1, 1, 1, 75, a2, a1);

            Console.WriteLine(test2);

            Console.WriteLine("=================TwoDayAirPackage====================");
            TwoDayAirPackage test3 = new TwoDayAirPackage(1, 1, 1, 1, a1, a3, TwoDayAirPackage.Delivery.Saver);

            Console.WriteLine(test3);
        }
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                                     "Louisville", "KY", 40202);    // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                                     "Beverly Hills", "CA", 90210); // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);       // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);      // Test Address 4

            Letter l1 = new Letter(a1, a3, 1.50M);                  // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.25M);                  // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.75M);                  // Test Letter 3

            //Groundpackage
            GroundPackage gP = new GroundPackage(a1, a2, 2.3, 4.5, 8.5, 98.5);

            //NextDayAirPackage
            NextDayAirPackage nextAP = new NextDayAirPackage(a2, a3, 5.5, 6.8, 8.9, 8.5, 1.5M);

            //TwoDayAirPackage
            TwoDayAirPackage twoDayAP = new TwoDayAirPackage(a3, a4, 8.5, 9.4, 7.5, 8.7, TwoDayAirPackage.Delivery.Saver);

            List <Parcel> parcels = new List <Parcel>(); // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);

            //add various packages
            parcels.Add(gP);
            parcels.Add(nextAP);
            parcels.Add(twoDayAP);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }
        }
예제 #7
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                "Louisville", "KY", 40202); // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                "Beverly Hills", "CA", 90210); // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                "El Paso", "TX", 79901); // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                "Portland", "ME", 04101); // Test Address 4

            Letter l1 = new Letter(a1, a3, 1.50M); // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.25M); // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.75M); // Test Letter 3

            GroundPackage t1 = new GroundPackage(a1, a2, 1, 2, 3, 4);
            NextDayAirPackage t2 = new NextDayAirPackage(a2, a3, 1, 2, 3, 4, 25);
            NextDayAirPackage t3 = new NextDayAirPackage(a2, a3, 50, 50, 50, 100, 125);
            TwoDayAirPackage t4 = new TwoDayAirPackage(a3, a4, 1, 2, 3, 4, TwoDayAirPackage.Delivery.Early);
            TwoDayAirPackage t5 = new TwoDayAirPackage(a3, a4, 50, 50, 50, 100, TwoDayAirPackage.Delivery.Saver);

            List<Parcel> parcels = new List<Parcel>(); // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);

            parcels.Add(t1);
            parcels.Add(t2);
            parcels.Add(t3);
            parcels.Add(t4);
            parcels.Add(t5);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }
        }
예제 #8
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                                     "Louisville", "KY", 40202);                                                                       // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                                     "Beverly Hills", "CA", 90210);                                                                    // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);                                                                          // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);                                                                         // Test Address 4

            Letter l1 = new Letter(a1, a3, 1.50M);                                                                                     // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.25M);                                                                                     // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.75M);                                                                                     // Test Letter 3

            GroundPackage     gp1                   = new GroundPackage(a1, a2, 10, 20, 30, 40);                                       // test ground package
            NextDayAirPackage tomorrowAirBox        = new NextDayAirPackage(a2, a3, 5, 15, 25, 35, 10.00M);                            // test bext day air package
            TwoDayAirPackage  getWhenYouGetAirBox   = new TwoDayAirPackage(a3, a4, 12, 234, 10, 200, TwoDayAirPackage.Delivery.Saver); // test bext day air package
            TwoDayAirPackage  mayComeNextWeekAirBox = new TwoDayAirPackage(a2, a4, 70, 30, 25, 150, TwoDayAirPackage.Delivery.Early);  // test bext day air package

            List <Parcel> parcels = new List <Parcel>();                                                                               // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);
            parcels.Add(gp1);
            parcels.Add(tomorrowAirBox);
            parcels.Add(getWhenYouGetAirBox);
            parcels.Add(mayComeNextWeekAirBox);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }
        }
예제 #9
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                                     "Louisville", "KY", 40202);                                                    // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                                     "Beverly Hills", "CA", 90210);                                                 // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);                                                       // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);                                                      // Test Address 4

            Letter            l1  = new Letter(a1, a3, 1.50M);                                                      // Test Letter 1
            Letter            l2  = new Letter(a2, a4, 1.25M);                                                      // Test Letter 2
            Letter            l3  = new Letter(a4, a1, 1.75M);                                                      // Test Letter 3
            GroundPackage     gp1 = new GroundPackage(a1, a2, 6, 4, 6, 5);                                          //Test Ground Package
            NextDayAirPackage ap1 = new NextDayAirPackage(a4, a1, 8, 4, 7, 10, 5);                                  //Test Next Day air package
            TwoDayAirPackage  ap2 = new TwoDayAirPackage(a2, a3, 33, 25, 40, 100, TwoDayAirPackage.Delivery.Early); //Test Two Day air package


            List <Parcel> parcels = new List <Parcel>(); // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);
            parcels.Add(gp1);
            parcels.Add(ap1);
            parcels.Add(ap2);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }
        }
예제 #10
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("  John Smith  ", "   123 Any St.   ", "  Apt. 45 ",
                                     "  Louisville   ", "  KY   ", 40202); // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.",
                                     "Beverly Hills", "CA", 90210);        // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);              // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);             // Test Address 4

            Letter l1 = new Letter(a1, a3, 0.50M);                         // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.20M);                         // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.70M);                         // Test Letter 3

            TwoDayAirPackage  p1 = new TwoDayAirPackage(a1, a2, 5, 4, 2, 3, 1);
            NextDayAirPackage p2 = new NextDayAirPackage(a4, a2, 9, 12, 6, 50, 6.99m);
            GroundPackage     p3 = new GroundPackage(a3, a1, 30, 15, 31, 100);

            List <Parcel> parcels = new List <Parcel>(); // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);
            parcels.Add(p1);
            parcels.Add(p2);
            parcels.Add(p3);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }
        }
예제 #11
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("  John Smith  ", "   123 Any St.   ", "  Apt. 45 ",
                                     "  Louisville   ", "  KY   ", 40202);                                               // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.",
                                     "Beverly Hills", "CA", 90210);                                                      // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);                                                            // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);                                                           // Test Address 4

            Letter l1 = new Letter(a1, a3, 0.50M);                                                                       // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.20M);                                                                       // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.70M);                                                                       // Test Letter 3

            GroundPackage gp1 = new GroundPackage(a2, a1, 5, 6, 7, 8);                                                   // Test GroundPackage 1
            GroundPackage gp2 = new GroundPackage(a4, a2, 75, 75, 75, 50);                                               // Test GroundPackage 2

            NextDayAirPackage nextDayAir1 = new NextDayAirPackage(a4, a3, 50, 50, 50, 25, 10);                           // Test NextDayAirPackage 1
            NextDayAirPackage nextDayAir2 = new NextDayAirPackage(a1, a3, 25, 25, 25, 100, 8);                           // Test NextDayAirPackage 2
            NextDayAirPackage nextDayAir3 = new NextDayAirPackage(a2, a4, 50, 50, 50, 100, 15);                          // Test NextDayAirPackage 3

            TwoDayAirPackage twoDayAir1 = new TwoDayAirPackage(a3, a2, 50, 25, 50, 30, TwoDayAirPackage.Delivery.Saver); // Test TwoDayAirPackage 1
            TwoDayAirPackage twoDayAir2 = new TwoDayAirPackage(a4, a1, 10, 10, 10, 10, TwoDayAirPackage.Delivery.Early); // Test TwoDayAirPackage 2

            List <Parcel> parcels = new List <Parcel>();                                                                 // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }

            List <Package> packages = new List <Package>(); // Test list of packages

            // Add test data to list
            packages.Add(gp1);
            packages.Add(gp2);
            packages.Add(nextDayAir1);
            packages.Add(nextDayAir2);
            packages.Add(nextDayAir3);
            packages.Add(twoDayAir1);
            packages.Add(twoDayAir2);

            // Display data
            Console.WriteLine("Program 1A - List of Packages\n");

            foreach (Package package in packages)
            {
                Console.WriteLine(package);
                Console.WriteLine("--------------------");
            }
        }
예제 #12
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                                     "Louisville", "KY", 40202);                                                    // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                                     "Beverly Hills", "CA", 90210);                                                 // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);                                                       // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);                                                      // Test Address 4
            Address a5 = new Address("James Haverstock", "10101 Linn Station Rd", "Suite 200",
                                     "Louisville", "KY", 40223);                                                    // Test Address 5
            Address a6 = new Address("Paul Jacob", "4107 SpyGlass Ct", "",
                                     "Louisville", "KY", 40229);                                                    // Test Address 6
            Address a7 = new Address("Laura Payne", "320 E Esplenade Ave", "",
                                     "Louisville", "KY", 40213);                                                    // Test Address 7
            Address a8 = new Address("Geraldine Spicer", "8601 Timberhallow Ct", "",
                                     "Louisville", "KY", 40219);                                                    // Test Address 8

            Letter            l1  = new Letter(a1, a3, 1.50M);                                                      // Test Letter 1
            Letter            l2  = new Letter(a2, a4, 1.25M);                                                      // Test Letter 2
            Letter            l3  = new Letter(a4, a1, 1.75M);                                                      // Test Letter 3
            GroundPackage     g1  = new GroundPackage(3, 6, 9, 12, a1, a6);                                         // Test GroundPackage 1
            GroundPackage     g2  = new GroundPackage(12, 9, 6, 3, a5, a8);                                         // Test GroundPackage 2
            GroundPackage     g3  = new GroundPackage(6, 7, 9, 100, a3, a7);                                        // Test GroundPackage 3
            NextDayAirPackage nA1 = new NextDayAirPackage(500, 12, 12, 12, 12, a4, a7);                             // Test NextDayAirPackage 1
            NextDayAirPackage nA2 = new NextDayAirPackage(20, 7, 7, 7, 70, a7, a2);                                 // Test NextDayAirPackage 2
            NextDayAirPackage nA3 = new NextDayAirPackage(5, 1, 2, 3, 4, a3, a1);                                   // Test NextDayAirPackage 3
            TwoDayAirPackage  tA1 = new TwoDayAirPackage(9, 9, 9, 200, a6, a3, TwoDayAirPackage.Delivery.Saver);    //Test TwoDayAirPackage 1
            TwoDayAirPackage  tA2 = new TwoDayAirPackage(10, 20, 30, 40, a7, a8, TwoDayAirPackage.Delivery.Early);  //Test TwoDayAirPackage 2
            TwoDayAirPackage  tA3 = new TwoDayAirPackage(100, 90, 80, 76, a4, a3, TwoDayAirPackage.Delivery.Saver); //Test TwoDayAirPackage 3

            List <Parcel> parcels = new List <Parcel>();                                                            // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);
            parcels.Add(g1);
            parcels.Add(g2);
            parcels.Add(g3);
            parcels.Add(nA1);
            parcels.Add(nA2);
            parcels.Add(nA3);
            parcels.Add(tA1);
            parcels.Add(tA2);
            parcels.Add(tA3);

            //Begin LINQ Queries
            //Query 1
            Console.WriteLine("=========================================");
            Console.WriteLine("This lists all parcels by their destination Zip in decending order.");
            Console.WriteLine();
            //Query that lists all parcels by destination zip in descending order.
            var dZip =
                from x in parcels                  //Temporary variable to hold parcels for LINQ queries
                orderby - x.DestinationAddress.Zip //list in descending order
                select x;

            foreach (var parcel in dZip) // Temporary variable to hold parcel objects for display
            {
                Console.WriteLine(parcel);
                Console.WriteLine("---------------------------");
                Console.WriteLine();
            }

            //Query 2
            Console.WriteLine("=========================================");
            Console.WriteLine("This lists all parcels by their cost in ascending order");
            Console.WriteLine();
            // query that lists all parcels by their cost in ascending order
            var costA =
                from x in parcels    //Temporary variable to hold parcels for LINQ queries
                orderby x.CalcCost() // Method used for calculating the cost of shipping a parcel in ascending order
                select x;

            foreach (var parcel in parcels)
            {
                Console.WriteLine(parcel);
                Console.WriteLine("---------------------------");
                Console.WriteLine();
            }

            //Query 3
            Console.WriteLine("=========================================");
            Console.WriteLine("This lists all parcels by their type.");
            Console.WriteLine();
            // query that lists all parcels by their respective types alphabetically
            var parcelT =
                from x in parcels    //Temporary variable to hold parcels for LINQ queries
                orderby x.GetType()  // Method used to get the type of the parcel
                orderby x.CalcCost() // Method used to get the cost of shipping a parcel in ascending order
                select x;

            foreach (var parcel in parcels) // Temporary variable to hold parcels for display in the foreach loop
            {
                Console.WriteLine(parcel.GetType().ToString());
                Console.WriteLine(parcel);
                Console.WriteLine("---------------------------");
                Console.WriteLine();
            }

            //Query 4
            Console.WriteLine("=========================================");
            Console.WriteLine("This shows all heavy airpackages and orders them by weight.");
            Console.WriteLine();
            // Query that lists only Heavy objects and sorts them by weight
            var airPackages =
                from x in parcels                //Temporary variable to hold parcels for LINQ queries
                where x is AirPackage && ((AirPackage)x).IsHeavy() == true
                let airP = (AirPackage)x         // Cast x as AirPackage and store in another temporary variable for sorting.
                           orderby - airP.Weight //list in descending order
                           select x;

            foreach (var airPackage in airPackages) //Temporary variable used to display airPackage objects
            {
                Console.WriteLine(airPackage);
                Console.WriteLine("------------------------------");
                Console.WriteLine();
            }
        }
예제 #13
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                                     "Louisville", "KY", 40202);    // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                                     "Beverly Hills", "CA", 90210); // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                                     "El Paso", "TX", 79901);       // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                                     "Portland", "ME", 04101);      // Test Address 4

            Letter l1 = new Letter(a1, a3, 1.50M);                  // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.25M);                  // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.75M);                  // Test Letter 3

            List <Parcel> parcels = new List <Parcel>();            // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }

            //New Ground packagages
            GroundPackage gp1 = new GroundPackage(a1, a3, 10, 20, 30, 40);
            GroundPackage gp2 = new GroundPackage(a2, a4, 3, 6, 9, 12);

            //New next day air packages
            NextDayAirPackage ndap1 = new NextDayAirPackage(a2, a3, 2, 4, 6, 8, 1.5M);
            NextDayAirPackage ndap2 = new NextDayAirPackage(a4, a1, 5, 10, 15, 20, 2.0M);

            //New two day air packages
            TwoDayAirPackage tdap1 = new TwoDayAirPackage(a3, a2, 1, 3, 5, 7, TwoDayAirPackage.Delivery.Early);
            TwoDayAirPackage tdap2 = new TwoDayAirPackage(a1, a4, 50, 40, 30, 20, TwoDayAirPackage.Delivery.Saver);

            //Test list of packages
            List <Package> packages = new List <Package>();

            packages.Add(gp1);
            packages.Add(gp2);
            packages.Add(ndap1);
            packages.Add(ndap2);
            packages.Add(tdap1);
            packages.Add(tdap2);

            //Display data
            Console.WriteLine("Program 1A - List of Packages \n\n");

            foreach (Package pckg in packages)
            {
                Console.WriteLine(pckg);
                Console.WriteLine("--------------------");
            }
        }