Ejemplo n.º 1
0
        }                  // 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);
        }
Ejemplo n.º 2
0
 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());
 }
Ejemplo n.º 3
0
 public int ToursCountByType(TypesOfTours type)
 {
     return(_tours.Count(tour => tour.Type == type));
 }