Example #1
0
        public void RemoveHouse()
        {
            int selection;

            do
            {
                Console.Clear();
                int numHouses = ViewHouses();
                Console.WriteLine("\nWhich house would you like to remove? (Enter the number, or ESC to cancel)\n");
                keyPressed = Console.ReadKey(true);
                if (Validate.IsEscape(keyPressed)) // user pressed the ESC key
                {
                    return;
                }
                selection = Validate.Range(keyPressed, 1, numHouses);
                if (selection != -1)
                {
                    House house = myHouses.ElementAt(selection - 1);
                    myHouses.Remove(house);
                    Console.Clear();
                    Console.WriteLine("\nHouse #" + selection + " has been condemned because it is infested with rabid wombats.\n\n");
                    ViewHouses();
                }
            }while (selection == -1);
        }
Example #2
0
        public void RemoveCar()
        {
            int selection;

            do
            {
                Console.Clear();
                int numCars = ViewCars();
                Console.WriteLine("Which car would you like to remove? (Enter the number, or ESC to cancel)\n");
                keyPressed = Console.ReadKey(true);
                if (Validate.IsEscape(keyPressed)) // user pressed the ESC key
                {
                    return;
                }
                selection = Validate.Range(keyPressed, 1, numCars);
                if (selection > -1)
                {
                    Car car = myCars.ElementAt(selection - 1);
                    myCars.Remove(car);
                    Console.Clear();
                    Console.WriteLine("\nCar #" + selection + " is gone because it has been eaten by wombats.\n\n");
                    ViewCars();
                }
            }while (selection == -1);
        }