示例#1
0
        static void Main(string[] args)
        {
            int    input;
            bool   flag = true;
            CarLot lot  = new CarLot();

            lot.InitializeInventory();
            do
            {
                Console.WriteLine("Welcome to Soc and Marks used car lot!!\nWhere the deals are bad and we love $$$$$$$$!!\n");

                input = lot.IntInput("1. Add Car\n2. Display Cars\n3. Sell Car\n4. Clear Console\n5. Quit\n >> ");
                Console.WriteLine();
                switch (input)
                {
                case 1:
                    lot.AddCar();
                    break;

                case 2:
                    lot.DisplayCars();
                    break;

                case 3:
                    lot.RemoveCar();
                    break;

                case 4:
                    Console.Clear();
                    break;

                case 5:
                    Console.WriteLine("Have a good day!");
                    flag = false;
                    break;

                default:
                    Console.WriteLine("That input does not exist. Please input a correct menu input >> ");
                    break;
                }
                Console.WriteLine();
            } while (flag);
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Laura and Sameer's car lot!");
            CarLot carlot = new CarLot();

            carlot.AddCar("Ford", "Mustang", 2020, 45000, 0);
            carlot.AddCar("Tesla", "Model S", 2020, 95000, 0);
            carlot.AddCar("Lamgorghini", "Aventador", 2020, 420000, 0);
            carlot.AddCar("Chevy", "Camaro", 2010, 11000, 10000);
            carlot.AddCar("Dodge", "Charger", 2010, 9000, 124000);
            carlot.AddCar("Mercedes-Benz", "G Wagon", 2015, 65000, 35000);

            bool flag = true;

            while (flag == true)
            {
                Console.WriteLine("\nWhat would you like to do? " +
                                  "\n1. List all cars" +
                                  "\n2. Buy a car" +
                                  "\n3. Add a car" +
                                  "\n4. Search" +
                                  "\n5. Quit");
                Console.Write("Enter choice here: ");

                int switchCase = InputInt();
                while (switchCase < 1 || switchCase > 5)
                {
                    Console.Write("That is not a valid input. Enter the following:" +
                                  "\n1. Add a team member" +
                                  "\n2. Search for a team member" +
                                  "\n3. Print all members" +
                                  "\n4. Quit");
                    switchCase = InputInt();
                }

                switch (switchCase)
                {
                case 1:
                    carlot.ListCars();
                    continue;

                case 2:
                    carlot.ListCars();
                    Console.Write("Enter the ID of the car you would like to buy: ");
                    int id = InputInt();
                    carlot.RemoveCar(id);
                    continue;

                case 3:
                    Console.WriteLine("Let's add a car to inventory.");
                    Console.Write("Year: ");
                    int year = int.Parse(Console.ReadLine());
                    Console.Write("Make: ");
                    string make = Console.ReadLine();

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

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

                    Console.Write("Mileage (enter 0 if new): ");
                    double mileage = double.Parse(Console.ReadLine());

                    carlot.AddCar(make, model, year, price, mileage);

                    Console.WriteLine($"You have just added a {year} {make} {model} for {price.ToString("C")}");
                    continue;

                case 4:
                    carlot.SearchCar();
                    continue;

                default:
                    flag = false;
                    break;
                }
                Console.WriteLine("Thank you for shopping at Laura and Sameer's car lot!");
                // flag = RunAgainBool("Do you want to continue? y/n: ");
            }
        }