Exemple #1
0
 /// <summary>
 /// Method CallEvent
 /// Calls delegate passed.
 /// </summary>
 private void CallEvent(CatalogEventArgs e, CatalogStateHandler handler)
 {
     if ((handler != null) && (e != null))
     {
         handler(this, e);
     }
 }
Exemple #2
0
        /// <summary>
        /// Method DisplayCountCar
        /// Displays information about the counting of car brands.
        /// </summary>
        private void DisplayCountBrand(CatalogEventArgs e)
        {
            ConsoleColor color = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine($"Number of car brands : {e.NumberOfCars}\n");
            Console.ForegroundColor = color;
        }
Exemple #3
0
        /// <summary>
        /// Method DisplayAddCar
        /// Displays information about the added car.
        /// </summary>
        private void DisplayAddCar(CatalogEventArgs e)
        {
            ConsoleColor color = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine($"Added car in the catalog. (ID : {e.Count})");
            Console.WriteLine($"Brand : {e.Brand}");
            Console.WriteLine($"Model : {e.Model}");
            Console.WriteLine($"Number of cars : {e.NumberOfCars}");
            Console.WriteLine($"Price : {e.Price}\n");
            Console.ForegroundColor = color;
        }
Exemple #4
0
        /// <summary>
        /// Method DisplayAverageCost
        /// Displays information on the calculation of the average price of cars.
        /// </summary>
        private void DisplayAverageCost(CatalogEventArgs e)
        {
            ConsoleColor color = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.DarkGray;
            if (e.Brand == string.Empty)
            {
                Console.WriteLine($"Average cost of the car : {e.Price}\n");
            }
            else
            {
                Console.WriteLine($"Average cost of {e.Brand} cars : {e.Price}\n");
            }
            Console.ForegroundColor = color;
        }
Exemple #5
0
 /// <summary>
 /// Method AverageCarPriceHandler
 /// The method that handles the event of calculating the average price of cars.
 /// </summary>
 public void AverageCarPriceHandler(object sender, CatalogEventArgs e)
 {
     DisplayAverageCost(e);
 }
Exemple #6
0
 /// <summary>
 /// Method CountCarHandler
 /// A method that handles a car counting event.
 /// </summary>
 public void CountTypeHandler(object sender, CatalogEventArgs e)
 {
     DisplayCountBrand(e);
 }
Exemple #7
0
 /// <summary>
 /// Method CountCarHandler
 /// A method that handles a car counting event.
 /// </summary>
 public void CountCarHandler(object sender, CatalogEventArgs e)
 {
     DisplayCountCar(e);
 }
Exemple #8
0
 /// <summary>
 /// Method AddedCarHandler
 /// The method that handles the event of adding a car.
 /// </summary>
 public void AddedCarHandler(object sender, CatalogEventArgs e)
 {
     DisplayAddCar(e);
 }