Ejemplo n.º 1
0
 //rent methood, throw mesaage every step that refort waht goes wrong
 public bool RentBook(double money, TextBlock info, User user)
 {
     if (a.getCopies() <= 0)
     {
         throw new Exception("Not in stock!");
     }
     if (money == -1)
     {
         throw new Exception("Please enter money only!");
     }
     if (money < a.getDiscountPrice())
     {
         throw new Exception("Please enter enought money!");
     }
     // if this pass all the conditions he rentable
     a.ReduceCopyAmount();                        //remove copy from our list
     info.Text = a.ToString();                    //print the current detail's
     user.RentItem(a);                            //add the item to list of the user
     BookLib.ItemCollection.addToRental(user, a); //add to the Dictionary that manage the rentel
     return(true);
 }