예제 #1
0
        public Car GetInfo()
        {
            Console.Write("Make:");
            string make = Console.ReadLine();

            Console.Write("Model:");
            string model = Console.ReadLine();

            Console.Write("year:");
            int year = int.Parse(Console.ReadLine());

            Console.Write("Price:");
            decimal price = decimal.Parse(Console.ReadLine());

            Console.WriteLine("if mileage is over 100 car will be considered used");
            Console.Write("Milage:");
            int mileage = int.Parse(Console.ReadLine());

            if (mileage > 100)
            {
                UsedCar car = new UsedCar(make, model, year, price, mileage);
                return(car);
            }
            else
            {
                Car car = new Car(make, model, year, price);
                return(car);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            CarLot Kathryn  = new CarLot("Kat's Kars");
            CarLot Dave     = new CarLot("Dave's Cars");
            int    location = 0;


            Car newcar = new UsedCar();

            CarLot.Lots[location].AddCar(newcar);

            for (int i = 0; i < 12; i++)
            {
                Car recentvette   = new Car("Chevy", "Corvette", 2000 + i, 50000m);
                Car recentMustang = new Car("Ford", "Mustang", 2000 + i, 50000m);
                CarLot.Lots[1].AddCar(recentvette);
                CarLot.Lots[0].AddCar(recentMustang);
            }


            do
            {
                int input = 0;
                location = LotChoice(CarLot.Lots);
                if (location == 1 || location == 0)
                {
                    do
                    {
                        Console.Clear();

                        CarLot.Lots[location].DisplayMenu();
                        input = GetInteger("Select an ID: ", CarLot.Lots[location]);
                        if (input <= CarLot.Lots[location].Inventory.Count)
                        {
                            CarLot.Lots[location].BuyaCar(input);
                        }
                        else if (input == CarLot.Lots[location].Inventory.Count + 2)
                        {
                            Console.WriteLine("Thank you for shopping");
                        }
                        else if (input == CarLot.Lots[location].Inventory.Count + 1)
                        {
                            CarLot.Lots[location].AddCar(CarLot.Lots[location].GetInfo());
                        }
                    } while (input != CarLot.Lots[location].Inventory.Count + 2);
                }
            } while (location != CarLot.Lots.Count);
            Console.WriteLine("Thank you foor using the car lot shopping app");
        }