Пример #1
0
 public Cost(IHasCost <T> master, IEnumerable <CostCategory <T> > categories)
 {
     m_master     = master;
     m_categories = new List <CostCategory <T> >();
     foreach (CostCategory <T> category in categories)
     {
         m_categories.Add(category.Clone());
     }
 }
Пример #2
0
 public bool TryToPurchase(IHasCost purchase)
 {
     if (Funds > purchase.Cost)
     {
         Funds -= purchase.Cost;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #3
0
 public static bool TryToPurchase(IHasFunds purchaser, IHasCost purchase, bool force = false)
 {
     if (force)
     {
         purchaser.Funds -= purchase.Cost;
         return(true);
     }
     if (purchaser.Funds < purchase.Cost)
     {
         return(false);
     }
     else
     {
         purchaser.Funds -= purchase.Cost;
         return(true);
     }
 }