public void AddCustomer(AbstCustomer c) { if (!IsCustomer(c)) { library.Customers.Add(c); addEvent("Added customer " + c.Id); } }
public void RemoveCustomer(AbstCustomer c) { if (IsCustomer(c)) { addEvent("Removed customer " + c.Id); library.Customers.Remove(c); } }
public int TotalPenalty(AbstCustomer c) { int penalty = 0; foreach (AbstBook b in c.Borrowed) { penalty += BookPenalty(b); } return(penalty); }
public void Return(AbstCustomer c) { addEvent("Returning books", c); Pay(c); foreach (AbstBook b in c.Borrowed) { AddToStock(b); } c.Borrowed.Clear(); }
public void addEvent(String s, AbstCustomer c) { library.addEvent(s + " by " + c.Id); int size = library.Events.Count(); library.Events[size - 1].GetInvoice.Books = new List <AbstBook>(c.Borrowed); //AbstEvent anEvent = new Event(s + " by " + c.Id); //AbstInvoice anInvoice = new Invoice(); //anEvent.GetInvoice = anInvoice; //anEvent.GetInvoice.Books = new List<AbstBook>(c.Borrowed); //library.Events.Add(anEvent); }
public bool AddToBasket(AbstCustomer c, AbstBook b) { if (IsCustomer(c) && IsInStock(b)) { c.Basket.Add(b); RemoveFromStock(b); addEvent("Added to basket of " + c.Id + " book " + b.Id); return(true); } else { return(false); } }
public bool Borrow(AbstCustomer c) { if (c.MoneyInCents > 0) { foreach (AbstBook b in c.Basket) { b.ReturnDate = DateTime.Today.AddDays(14); c.Borrowed.Add(b); } addEvent("Borrowing books", c); c.Basket.Clear(); return(true); } else { return(false); } }
public void AddFunds(AbstCustomer c, int moneyInCents) { c.MoneyInCents += moneyInCents; addEvent("Added " + moneyInCents + " cents to account of " + c.Id); }
public bool IsCustomer(AbstCustomer c) { return(library.Customers.Contains(c) ? true : false); }
public void Pay(AbstCustomer c) { c.MoneyInCents -= TotalPenalty(c); }