public static void UserAddedCar()
        {
            Console.WriteLine("Enter the make:");
            var makeofCar = Console.ReadLine();

            Console.WriteLine("Enter the model:");
            var modelofCar = Console.ReadLine();

            Console.WriteLine("Enter the year:");
            int.TryParse(Console.ReadLine(), out int yearofCar);


            Console.WriteLine("What is the price?");
            double.TryParse(Console.ReadLine(), out double priceofCar);

            Console.WriteLine("How many miles ?");
            double.TryParse(Console.ReadLine(), out double milesofCar);

            CarLot.AddCar(new UsedCar(makeofCar, modelofCar, yearofCar, priceofCar, milesofCar));
        }
        static void Main(string[] args)
        {
            CarLot.carType.Add(new Car("Nikolai", "Model S", 2017, 54999.90));
            CarLot.carType.Add(new Car("Ford", "Escape", 2017, 31999.90));
            CarLot.carType.Add(new Car("Chewie", "Vette", 2017, 44989.95));
            CarLot.carType.Add(new UsedCar("Hyonda", "Prior", 2015, 14795.90, 35987.6));
            CarLot.carType.Add(new UsedCar("GC", "Chirpus", 2013, 8500.00, 12345));
            CarLot.carType.Add(new UsedCar("GC", "Witherall", 2016, 14450.00, 3500.3));



            Console.WriteLine("Welcome to Grant Chirpus' Used Car Emporium! \n");



            bool again = true;

            while (again)
            {
                again = CarLot.ListofCars();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Car car1 = new Car("Tesla", "Model S", 2020, 80000.00m);
            Car car2 = new Car("Chevrolet", "Camaro", 2020, 50000.00m);
            Car car3 = new Car("Jeep", "Wrangler", 2020, 60000.00m);
            Car car4 = new UsedCar("Pontiac", "Firebird", 1995, 5000.00m, 89000);
            Car car5 = new UsedCar("Ford", "F150", 1997, 3000.00m, 100000);
            Car car6 = new UsedCar("Chrysler", "300", 2010, 8000.00m, 65000);



            bool isRunning = true;

            while (isRunning)
            {
                int num1 = CarLot.GetNumber() + 1;
                int num2 = CarLot.GetNumber() + 2;
                int num3 = CarLot.GetNumber() + 3;
                int num4 = CarLot.GetNumber() + 4;

                Console.WriteLine("Welcome to the car lot, what would you like to do?");
                CarLot.ViewCars();
                Console.WriteLine($"{num1}. Add a Car.");
                Console.WriteLine($"{num2}. Buy a Car.");
                Console.WriteLine($"{num3}. Quit.");

                bool isValid = int.TryParse(Console.ReadLine(), out int number);
                while (!isValid || number >= num4)
                {
                    Console.WriteLine("Please enter a valid answer. ");
                    isValid = int.TryParse(Console.ReadLine(), out number);
                }

                if (number == num1)
                {
                    BuildCar();
                }
                if (number == num2)
                {
                    Console.Clear();
                    CarLot.ViewCars();

                    Console.WriteLine("Which car do you want to buy?");
                    isValid = int.TryParse(Console.ReadLine(), out int choice);
                    while (!isValid || choice > CarLot.GetNumber())
                    {
                        Console.WriteLine("Sorry, that's not on our list.");
                        isValid = int.TryParse(Console.ReadLine(), out choice);
                    }

                    Console.Clear();
                    CarLot.ShowcaseCar(choice);
                    Console.WriteLine("Are you sure you want to buy this vehicle? (Y/N)");

                    bool isStillRunning = true;
                    while (isStillRunning)
                    {
                        string signDocs = Console.ReadLine().ToLower();
                        if (signDocs == "y")
                        {
                            CarLot.Remove(choice);
                            Console.WriteLine("Thanks for shopping with us!");
                            Console.WriteLine("Press enter to return to the menu.");
                            Console.ReadLine();
                            break;
                        }
                        else if (signDocs == "n")
                        {
                            return;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    //Console.ReadLine();
                }
                if (number == num3)
                {
                    Environment.Exit(1);
                }
                else
                {
                    continue;
                }
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Kyle Nedbal's Used Car Emporium!");
            Console.WriteLine();

            CarLot.cars.Add(new NewCar("Tesla", "Roadster", 2021, 130000.00));
            CarLot.cars.Add(new NewCar("Ford", "Mustang Mach-EV", 2021, 42500.00));
            CarLot.cars.Add(new NewCar("GMC", "Hummer EV", 2021, 105000.00));
            CarLot.cars.Add(new UsedCar("Lincoln", "Continental", 2018, 32000.00, 25000.00));
            CarLot.cars.Add(new UsedCar("Chevrolet", "Blazer RS", 2019, 29000.00, 36000.00));
            CarLot.cars.Add(new UsedCar("Jeep", "Grand Cherokee", 2017, 28000.00, 40000.00));

            bool userWantsToContinue = true;
            bool userChoice;

            do
            {
                do
                {
                    CarLot.ListCars(CarLot.cars);
                    Console.Write("Which car would you like?: ");
                    int validUserChoice;
                    userChoice = Int32.TryParse(Console.ReadLine(), out validUserChoice);
                    Console.WriteLine();

                    if (userChoice && validUserChoice > 0 && validUserChoice <= CarLot.cars.Count + 2)
                    {
                        if (validUserChoice > 0 && validUserChoice <= CarLot.cars.Count)
                        {
                            CarLot.cars[validUserChoice - 1].ToString();

                            Console.Write("Would you like to buy this car? (y/n): ");
                            string buyYN = Console.ReadLine().ToLower();
                            while (buyYN != "n" && buyYN != "y")
                            {
                                Console.Write("Please enter y or n to choose whether you'd like to buy this car: ");
                                buyYN = Console.ReadLine().ToLower();
                            }

                            if (buyYN == "y")
                            {
                                CarLot.RemoveCar(CarLot.cars[validUserChoice - 1]);
                                Console.WriteLine("Excellent! Our finance department will be in touch shortly");
                                Console.WriteLine();
                            }
                        }

                        else if (validUserChoice == CarLot.cars.Count + 1)
                        {
                            Console.Write("Enter the make: ");
                            string userMake = Console.ReadLine();
                            Console.Write("Enter the model: ");
                            string userModel = Console.ReadLine();
                            Console.Write("Enter the year: ");
                            int userYear = Int32.Parse(Console.ReadLine());
                            Console.Write("Enter the value of the car: ");
                            double userPrice = Double.Parse(Console.ReadLine());
                            Console.Write("Enter the mileage: ");
                            double userMileage = Double.Parse(Console.ReadLine());

                            CarLot.AddCar(new UsedCar(userMake, userModel, userYear, userPrice, userMileage));
                        }
                        else
                        {
                            userWantsToContinue = false;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid choice. Please enter the corresponding number to your choice showing on the list");
                    }
                } while (userChoice == false);
            } while (userWantsToContinue == true);

            Console.WriteLine("Have a great day!");
        }