예제 #1
0
파일: Meal.cs 프로젝트: pemski/restaurant
        /// <summary>
        /// Creates a Meal object.
        /// </summary>
        /// <param name="name">Name of thr meal</param>
        /// <param name="cost">Cost of thr meal</param>
        /// <param name="currency">Currency of the cost</param>
        /// <param name="type">Type of thr meal (pizza, soup, etc.)</param>
        /// <param name="availableAdditivesFactory">Object which creates a collection of available additives for the meal</param>
        /// <param name="availableMandatoryAdditivesFactory">Object which creates a collection of available additives for the meal from which one must be added to the meal (rice, potatoes, etc.)</param>
        /// <param name="additiveCollection">A collection to which selected additives are added</param>
        public Meal(string name, decimal cost, string currency, MealType type, IAdditiveFactory availableAdditivesFactory, IAdditiveFactory availableMandatoryAdditivesFactory, IAdditiveCollection additiveCollection)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("name", "Meal constructor: name cannot be empty or null.");
            }

            if (cost < 0)
            {
                throw new ArgumentOutOfRangeException("cost", "Meal constructor: cost cannot be lesser than 0.");
            }

            if (String.IsNullOrWhiteSpace(currency))
            {
                throw new ArgumentNullException("currency", "Meal constructor: currency cannot be empty or null.");
            }

            if (availableAdditivesFactory == null)
            {
                throw new ArgumentNullException("availableAdditivesFactory", "Meal constructor.");
            }

            if (availableMandatoryAdditivesFactory == null)
            {
                throw new ArgumentNullException("availableMandatoryAdditives", "Meal constructor.");
            }

            this.Type = type ?? throw new ArgumentNullException("type", "Meal constructor: meal type cannot be null.");
            this.SelectedAdditives = additiveCollection ?? throw new ArgumentNullException("additiveCollection", "Meal constructor");
            this.Name                        = name;
            this.Cost                        = cost;
            this.Currency                    = currency;
            this.availableAdditives          = availableAdditivesFactory.CreateAdditives();
            this.availableMandatoryAdditives = availableMandatoryAdditivesFactory.CreateAdditives();
        }
예제 #2
0
파일: Meal.cs 프로젝트: pemski/restaurant
 /// <summary>
 /// Creates a Meal object. Sets Currency field as default value: "zł".
 /// </summary>
 /// <param name="name">Name of the meal</param>
 /// <param name="cost">Cost of the meal</param>
 /// <param name="type">Type of the meal (pizza, soup, etc.)</param>
 /// <param name="availableAdditivesFactory">Object which creates a collection of available additives for the meal</param>
 /// <param name="availableMandatoryAdditivesFactory">Object which creates a collection of available additives for the meal from which one must be added to the meal (rice, potatoes, etc.)</param>
 /// <param name="additiveCollection">A collection to which selected additives are added</param>
 public Meal(string name, decimal cost, MealType type, IAdditiveFactory availableAdditivesFactory, IAdditiveFactory availableMandatoryAdditivesFactory, IAdditiveCollection additiveCollection)
     : this(name, cost, "zł", type, availableAdditivesFactory, availableMandatoryAdditivesFactory, additiveCollection)
 {
 }