/// <summary> /// Method CallEvent /// Calls delegate passed. /// </summary> private void CallEvent(CatalogEventArgs e, CatalogStateHandler handler) { if ((handler != null) && (e != null)) { handler(this, e); } }
/// <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; }
/// <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; }
/// <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; }
/// <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); }
/// <summary> /// Method CountCarHandler /// A method that handles a car counting event. /// </summary> public void CountTypeHandler(object sender, CatalogEventArgs e) { DisplayCountBrand(e); }
/// <summary> /// Method CountCarHandler /// A method that handles a car counting event. /// </summary> public void CountCarHandler(object sender, CatalogEventArgs e) { DisplayCountCar(e); }
/// <summary> /// Method AddedCarHandler /// The method that handles the event of adding a car. /// </summary> public void AddedCarHandler(object sender, CatalogEventArgs e) { DisplayAddCar(e); }