示例#1
0
        string GenerateCarsModel(CarsBrand brand)
        {
            Random rnd = new Random();
            int    key = rnd.Next(1, 4);

            return(brand.ToString() + "_Model" + key.ToString());
        }
示例#2
0
        static void Main(string[] args)
        {
            CarsShop carsShop = new CarsShop();

            while (true)
            {
                Console.WriteLine("Entar the car's model: Kia, Audi or Ford");
                CarsBrand costomersCarsBrand = (CarsBrand)Enum.Parse(typeof(CarsBrand), Console.ReadLine(), ignoreCase: true);

                Console.WriteLine("How much will you pay");
                decimal.TryParse(Console.ReadLine(), out decimal costomersPrice);

                carsShop.SearchModel(costomersCarsBrand, costomersPrice);

                Console.WriteLine("If you want to buy the car please enter carsID else enter \"0\"  to continue ");
                string carsID = Console.ReadLine();
                if (carsID == "0")
                {
                    break;
                }
                else
                {
                    carsShop.CellCar(carsID);
                    Console.WriteLine();
                }

                Console.WriteLine("Enter any button to continue shopping or \"C\" for close");
                string enter = Console.ReadLine();
                if (enter.ToLower() == "c")
                {
                    break;
                }
            }
        }
示例#3
0
 public Car()
 {
     ID        = GenerateID(ref counter);
     brand     = GenerateCarsBrand();
     carsModel = GenerateCarsModel(brand);
     color     = GenerateCarsColor();
     price     = GeneratePrice();
 }
示例#4
0
 public void SearchModel(CarsBrand costomersCarsBrand, decimal costomersPrice)
 {
     for (int i = 0; i < Cars.Count; i++)
     {
         if (costomersCarsBrand == Cars[i].brand && costomersPrice >= Cars[i].price)
         {
             Cars[i].PrintInformation();
             Console.WriteLine();
         }
     }
 }