public void Input(string manufacturer, string model, uint amount, double price) { CarDealer carDealer = CarDealer.GetInstance(); for (int i = 0; i < amount; i++) { carDealer.AddCar(new Car(manufacturer, model, price)); } }
public string CalculateAveragePrice(string type) { double amount = CarDealer.GetInstance().Cars.Where(x => x.Manufacturer == type).Count(); if (amount > 0) { double sumPrice = CarDealer.GetInstance().Cars.Where(x => x.Manufacturer == type).Select(x => x.Price).Sum(); return((sumPrice / amount).ToString()); } else { return("There're any cars of this manufacturer added!"); } }
public string CalculateAveragePrice() { double amount = CarDealer.GetInstance().Cars.Count(); if (amount > 0) { double sumPrice = CarDealer.GetInstance().Cars.Select(x => x.Price).Sum(); return((sumPrice / amount).ToString()); } else { return("There're any cars added!"); } }
public string CountTypes() { return(CarDealer.GetInstance().Cars.Select(x => x.Manufacturer).Distinct().Count().ToString()); }
public string CountAll() { return(CarDealer.GetInstance().Cars.Count.ToString()); }