Ejemplo n.º 1
0
 public void PrintAvailableItems()
 {
   Console.WriteLine("Items that can be checked out: ");
   for (int i = 0; i < Checkouts.Count; i++)
   {
     ICheckoutable item = Checkouts[i];
     if (item is Book)
     {
       Book book = (Book)item;//explicit type casting (force after checking w/ is)
       Console.WriteLine($"{i + 1}. Type={book.PubType}: {book.Title} -- {book.Author} ");
     }
     Magazine newMag = item as Magazine;//implicit type casting, try and check for null
     if (newMag != null)
     {
       Console.WriteLine($"{i + 1}. Type={newMag.PubType}: {newMag.Title} -- {newMag.Volume} ");
     }
   }
 }//end of printavailabeitems
Ejemplo n.º 2
0
 public void AddItem(ICheckoutable newItem)
 {
   Checkouts.Add(newItem);
 }