Beispiel #1
0
 /// <summary>
 /// Mixes the many.
 /// </summary>
 /// <param name="supps">The supps.</param>
 public void MixMany(TSupplementItem[] supps)
 {
     double amountSum = 0.0;
     for (int idx = 0; idx < supps.Length; idx++)
     {
         if (supps[idx].Amount > 0.0)
         {
             Mix(supps[idx], this, supps[idx].Amount / (amountSum + supps[idx].Amount));
             amountSum += supps[idx].Amount;
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Assigns the specified source ration.
 /// </summary>
 /// <param name="srcRation">The source ration.</param>
 public void Assign(TSupplementRation srcRation)
 {
     Array.Resize(ref fSuppts, srcRation.Count);
     for (int idx = 0; idx < srcRation.Count; idx++)
     {
         if (fSuppts[idx] == null)
             fSuppts[idx] = new TSupplementItem();
         fSuppts[idx].Assign(srcRation[idx]);
     }
     rationChoice = srcRation.rationChoice;
 }
Beispiel #3
0
 /// <summary>
 /// Inserts the specified index.
 /// </summary>
 /// <param name="idx">The index.</param>
 /// <param name="supp">The supp.</param>
 /// <param name="amt">The amt.</param>
 /// <param name="cost">The cost.</param>
 public void Insert(int idx, TSupplement supp, double amt = 0.0, double cost = 0.0)
 {
     Array.Resize(ref fSuppts, fSuppts.Length + 1);
     for (int jdx = fSuppts.Length - 1; jdx > idx; jdx--)
         fSuppts[jdx] = fSuppts[jdx - 1];
     fSuppts[idx] = new TSupplementItem(supp, amt, cost);
 }
Beispiel #4
0
 /// <summary>
 /// Adds the specified supp item.
 /// </summary>
 /// <param name="suppItem">The supp item.</param>
 /// <returns></returns>
 public int Add(TSupplementItem suppItem)
 {
     return Add(suppItem, suppItem.Amount, suppItem.Cost);
 }
Beispiel #5
0
 /// <summary>
 /// Gets or sets the <see cref="TSupplementItem"/> with the specified index.
 /// </summary>
 /// <value>
 /// The <see cref="TSupplementItem"/>.
 /// </value>
 /// <param name="idx">The index.</param>
 /// <returns></returns>
 public TSupplementItem this[int idx]
 {
     get
     {
         return fSuppts[idx];
     }
     set
     {
         // Note: Assigning to the Suppt property copies the attributes of the source
         // TSupplement, not the TSupplement instance itself.
         if (idx >= fSuppts.Length)
         {
             Array.Resize(ref fSuppts, (int)idx + 1);
             fSuppts[idx] = new TSupplementItem(value);
         }
     }
 }
Beispiel #6
0
 /// <summary>
 /// Inserts the specified index.
 /// </summary>
 /// <param name="idx">The index.</param>
 /// <param name="sName">Name of the s.</param>
 /// <param name="amount">The amount.</param>
 /// <param name="cost">The cost.</param>
 public void Insert(int idx, string sName, double amount = 0.0, double cost = 0.0)
 {
     TSupplementItem defSupp = new TSupplementItem();
     GetDefaultSupp(sName, ref defSupp);
     Insert(idx, defSupp, amount, cost);
 }
Beispiel #7
0
        /// <summary>
        /// Locates a supplement by name in the DefaultSupptCosts array and returns it
        /// </summary>
        /// <param name="sName">Name of the s.</param>
        /// <param name="suppt">The suppt.</param>
        /// <returns></returns>
        public bool GetDefaultSupp(string sName, ref TSupplementItem suppt)
        {
            int idx = DefaultSuppConsts.IndexOf(sName);
            bool result = idx >= 0;

            if (result)
            {
                if (suppt == null)
                    suppt = new TSupplementItem();
                suppt.Assign(DefaultSuppConsts[idx]);
            }
            return result;
        }
Beispiel #8
0
 /// <summary>
 /// Assigns the specified source supp.
 /// </summary>
 /// <param name="srcSupp">The source supp.</param>
 public void Assign(TSupplementItem srcSupp)
 {
     if (srcSupp != null)
     {
         base.Assign(srcSupp);
         Amount = srcSupp.Amount;
         Cost = srcSupp.Cost;
     }
 }