public Outings(TypeOfOutings type, double cpp, DateTime ed, int noppl) { Type = type; CostPerPerson = cpp; EventDate = ed; NumberOfPeople = noppl; TotalCost = cpp * noppl; }
public double CostByType(TypeOfOutings OType) { double totalCost = 0; foreach (Outings item in listOfOutings) { if (item.Type == OType) { totalCost += item.TotalCost; } } return(totalCost); }
public void TotalCostByType() { List <Outings> outingList = _outingsRepository.GetOutingList(); int choice; double totalCost = 0; Console.WriteLine("Please select which type you would like to get it's total:\n" + "1. Golf" + "2. Bowling\n" + "3. Amusement Park\n" + "4. Concert\n"); choice = int.Parse(Console.ReadLine()); TypeOfOutings outing = TypeOfOutings.AmusementPark; switch (choice) { case 1: outing = TypeOfOutings.Golf; break; case 2: outing = TypeOfOutings.Bowling; break; case 3: outing = TypeOfOutings.AmusementPark; break; case 4: outing = TypeOfOutings.Concert; break; } totalCost = _outingsRepository.CostByType(outing); Console.WriteLine($"Total cost of the selected type is: {totalCost}"); Run(); }