コード例 #1
0
        private void AddingAnotherVehicleFinalStep(Lists lists, Economy economy)
        {
            Console.Clear();

            if (newVehicleUsedOrNew == "Begagnad")
            {
                Console.WriteLine("Begagnat fordon");
            }
            else
            {
                Console.WriteLine("Nytt fordon");
            }

            Console.WriteLine("---");

            Console.Write("{0}ns tillverkare: ", newVehicleCarorMotorcycle);
            string newVehicleManufacturer = Console.ReadLine();

            Console.Write("{0}ns modell: ", newVehicleCarorMotorcycle);
            string newVehicleModel = Console.ReadLine();

            Console.Write("{0}ns pris: ", newVehicleCarorMotorcycle);
            int newVehiclePrice = int.Parse(Console.ReadLine());

            Console.Write("{0}ns tillverkningsår: ", newVehicleCarorMotorcycle);
            int newVehicleManufacturedYear = int.Parse(Console.ReadLine());

            Console.Write("Antal fordon att lägga till av modellen: ");
            int newVehicleAmount = int.Parse(Console.ReadLine());

            if (newVehicleUsedOrNew == "Begagnad")
            {
                Console.Write("Antal tidigare ägare: ");
                int newVehiclePreviousOwners = int.Parse(Console.ReadLine());

                if (newVehicleCarorMotorcycle == "Bile")
                {
                    Console.WriteLine("Lagrar följande: {0} {1}. {2} kronor. {3} tidigare ägare från {4}. {5} stycken till lagret.", newVehicleManufacturer, newVehicleModel, newVehiclePrice, newVehiclePreviousOwners, newVehicleManufacturedYear, newVehicleAmount);

                    UsedVehicle.Add(new UsedCar((newVehiclePrice + economy.RandomizedCreatedCarPrice()),
                                                newVehicleManufacturedYear,
                                                newVehicleManufacturer,
                                                newVehicleModel,
                                                newVehiclePreviousOwners,
                                                newVehicleAmount));

                    ForSaleUsedVehicle.Add(new ForSaleUsedCar((newVehiclePrice + economy.RandomizedCreatedCarPrice()),
                                                              newVehicleManufacturedYear,
                                                              newVehicleManufacturer,
                                                              newVehicleModel,
                                                              newVehiclePreviousOwners,
                                                              1000));
                }
                else if (newVehicleCarorMotorcycle == "Motorcykel")
                {
                    Console.WriteLine("Lagrar följande: {0} {1}. {2} kronor. {3} tidigare ägare från {4}. {5} stycken till lagret.", newVehicleManufacturer, newVehicleModel, newVehiclePrice, newVehiclePreviousOwners, newVehicleManufacturedYear, newVehicleAmount);

                    UsedVehicle.Add(new UsedMotorCycle((newVehiclePrice + economy.RandomizedCreatedCarPrice()),
                                                       newVehicleManufacturedYear,
                                                       newVehicleManufacturer,
                                                       newVehicleModel,
                                                       newVehiclePreviousOwners,
                                                       newVehicleAmount));
                    ForSaleUsedVehicle.Add(new ForSaleUsedMotorCycle((newVehiclePrice + economy.RandomizedCreatedCarPrice()),
                                                                     newVehicleManufacturedYear,
                                                                     newVehicleManufacturer,
                                                                     newVehicleModel,
                                                                     newVehiclePreviousOwners,
                                                                     1000));
                }
            }
            else if (newVehicleUsedOrNew == "Ny")
            {
                Console.Write("Garantiperiod: ");
                int newVehicleWarrantyPeriod = int.Parse(Console.ReadLine());

                if (newVehicleCarorMotorcycle == "Bile")
                {
                    Console.WriteLine("Lagrar följande: {0} {1}. {2} kronor. {3} års garanti. Tillverkad {4}. {5} stycken till lagret.", newVehicleManufacturer, newVehicleModel, newVehiclePrice, newVehicleWarrantyPeriod, newVehicleManufacturedYear, newVehicleAmount);

                    NewVehicle.Add(new Car((newVehiclePrice + economy.RandomizedCreatedCarPrice()),
                                           newVehicleManufacturedYear,
                                           newVehicleManufacturer,
                                           newVehicleModel,
                                           newVehicleWarrantyPeriod,
                                           newVehicleAmount));
                    ForSaleNewVehicle.Add(new ForSaleCar((newVehiclePrice + economy.RandomizedCreatedCarPrice()),
                                                         newVehicleManufacturedYear,
                                                         newVehicleManufacturer,
                                                         newVehicleModel,
                                                         newVehicleWarrantyPeriod,
                                                         1000));
                }
                else if (newVehicleCarorMotorcycle == "Motorcykel")
                {
                    Console.WriteLine("Lagrar följande: {0} {1}. {2} kronor. {3} års garanti. Tillverkad {4}. {5} stycken till lagret.", newVehicleManufacturer, newVehicleModel, newVehiclePrice, newVehicleWarrantyPeriod, newVehicleManufacturedYear, newVehicleAmount);

                    NewVehicle.Add(new Motorcycle((newVehiclePrice + economy.RandomizedCreatedCarPrice()),
                                                  newVehicleManufacturedYear,
                                                  newVehicleManufacturer,
                                                  newVehicleModel,
                                                  newVehicleWarrantyPeriod,
                                                  newVehicleAmount));
                    ForSaleNewVehicle.Add(new ForSaleMotorcycle((newVehiclePrice + economy.RandomizedCreatedCarPrice()),
                                                                newVehicleManufacturedYear,
                                                                newVehicleManufacturer,
                                                                newVehicleModel,
                                                                newVehicleWarrantyPeriod,
                                                                1000));
                }
            }
            listAddAnotherVehicleLoop = false;
            listAddNewVehicle         = false;

            ListUpdater();
            Console.WriteLine("(Tryck Enter för att återgå till menysystemet)");
            Console.ReadLine();
        }