Example #1
0
 public void AddCustomer(AbstCustomer c)
 {
     if (!IsCustomer(c))
     {
         library.Customers.Add(c);
         addEvent("Added customer " + c.Id);
     }
 }
Example #2
0
 public void RemoveCustomer(AbstCustomer c)
 {
     if (IsCustomer(c))
     {
         addEvent("Removed customer " + c.Id);
         library.Customers.Remove(c);
     }
 }
Example #3
0
        public int TotalPenalty(AbstCustomer c)
        {
            int penalty = 0;

            foreach (AbstBook b in c.Borrowed)
            {
                penalty += BookPenalty(b);
            }
            return(penalty);
        }
Example #4
0
        public void Return(AbstCustomer c)
        {
            addEvent("Returning books", c);

            Pay(c);
            foreach (AbstBook b in c.Borrowed)
            {
                AddToStock(b);
            }
            c.Borrowed.Clear();
        }
Example #5
0
        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);
        }
Example #6
0
 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);
     }
 }
Example #7
0
 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);
     }
 }
Example #8
0
 public void AddFunds(AbstCustomer c, int moneyInCents)
 {
     c.MoneyInCents += moneyInCents;
     addEvent("Added " + moneyInCents + " cents to account of " + c.Id);
 }
Example #9
0
 public bool IsCustomer(AbstCustomer c)
 {
     return(library.Customers.Contains(c) ? true : false);
 }
Example #10
0
 public void Pay(AbstCustomer c)
 {
     c.MoneyInCents -= TotalPenalty(c);
 }