Esempio n. 1
0
 public void AddCars()
 {
     do
     {
         Console.Clear();
         Car car = new Car();
         int retVal;
         do
         {
             Console.WriteLine("Enter the year: ");
             car.year = Console.ReadLine();
             retVal   = (int)Validate.Range(car.year, 1900, DateTime.Now.Year);
         } while (retVal == -1);
         Console.WriteLine("Enter the make: ");
         car.make = Console.ReadLine();
         Console.WriteLine("Enter the model: ");
         car.model = Console.ReadLine();
         myCars.Add(car);
         do
         {
             Console.WriteLine("Would you like to add another car? (Y/N)");
             keyPressed = Console.ReadKey(true);
         } while (!Validate.IsYesNo(keyPressed));
     } while (keyPressed.Key == ConsoleKey.Y);
 }
Esempio n. 2
0
        public void AddHouse()
        {
            do
            {
                House house = new House();
                int   selection;

                do
                {
                    Console.Clear();
                    Console.WriteLine("\nWhat type of house would you like to enter (1 or 2):\n");
                    Console.WriteLine("1. Single Family Residence");
                    Console.WriteLine("2. Townhome or Condo\n\n");
                    selection = Validate.Range(Console.ReadKey(true), 1, 2);
                    switch (selection)
                    {
                    case 1:
                        house.type = "Single Family Residence";
                        break;

                    case 2:
                        house.type = "Apartment or Condo";
                        break;
                    }
                } while (selection == -1);

                bool    retVal;
                decimal result;
                do
                {
                    Console.WriteLine("\nHow many bedrooms?");
                    house.bedrooms = Console.ReadLine();
                    retVal         = Validate.IsNumber(house.bedrooms, out result);
                } while (!retVal);
                do
                {
                    Console.WriteLine("\nHow many bathrooms?");
                    house.bathrooms = Console.ReadLine();
                    retVal          = Validate.IsNumber(house.bathrooms, out result);
                } while (!retVal);
                do
                {
                    Console.WriteLine("\nEnter the square footage:");
                    house.sqft = Console.ReadLine();
                    retVal     = Validate.IsNumber(house.sqft, out result);
                } while (!retVal);

                myHouses.Add(house);

                do
                {
                    Console.WriteLine("\nEnter another house? (Y/N)\n");
                    keyPressed = Console.ReadKey(true);
                } while (!Validate.IsYesNo(keyPressed));
            } while (keyPressed.Key == ConsoleKey.Y);
        }