} // default constructor protected Tour( string name, int duration, decimal price, string location, TypesOfTours typesOfTours, string description, DateTime tourStart ) { Name = name ?? throw new ArgumentNullException(nameof(name)); // check null if (duration <= 0) { throw new ArgumentException(nameof(duration)); // check validity of parameters } Duration = duration; if (price < 0) { throw new ArgumentException(nameof(duration)); // check validity of parameters } Price = price; Location = location ?? throw new ArgumentNullException(nameof(location)); // check null Type = typesOfTours; Description = description ?? throw new ArgumentNullException(nameof(description)); // check null TourStart = tourStart; TourEnd = TourStart.AddDays(Duration); }
public List <Tour> ListToursByType(TypesOfTours type) { /* * input data: type - specific type of tour * return data: list of tours that match this type */ return(_tours.Where(t => t.Type == type).ToList()); }
public int ToursCountByType(TypesOfTours type) { return(_tours.Count(tour => tour.Type == type)); }