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()); } }
public bool TryToPurchase(IHasCost purchase) { if (Funds > purchase.Cost) { Funds -= purchase.Cost; return(true); } else { return(false); } }
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); } }