title: how do you calculate and return a total value in c#?
body: <p>I'm, trying to add a method <code>Takings</code> which calculates and returns the total value of all the bookings for this show. If anyone could lead me in the right direction that would be great :)</p>
  <pre><code> namespace GCUShows
   {
   public class Show
   {
      private string title;
      private Dictionary&lt;int, Booking&gt; bookings;
  
      public string Title
      {
          get { return title; }
          set { title = value; }
      }
  
      public Show(string title)
      {
          this.title = title;
          this.bookings = new Dictionary&lt;int, Booking&gt;();
      }
  
      public void AddBooking(int bookingID, Booking booking)
      {
          this.bookings.Add(bookingID, booking);
      }
  
      public void RemoveBooking(int bookingID, Booking booking)
      {
          this.bookings.Remove(bookingID);
      }
      public Takings
      {
      }
  }
  
  
  namespace GCUShows
  {
  public enum TicketType
  {
      Adult,
      Child,
      Family
  }
  
  public class Booking : ITicket
  {
      private const int LIMIT = 6;
  
      public Show show;
      private int bookingID;
      public List&lt;ITicket&gt; tickets;
      
      public int BookingID
      {
          get { return bookingID; }
          set { bookingID = value; }
      }
     
      public Booking(Show show)
      {
          this.BookingID = BookingIDSequence.Instance.NextID;
          this.show = show;
          show.AddBooking(this);
          this.tickets = new List&lt;ITicket&gt;();
      }
  
      public void AddTickets(int number, TicketType type, decimal fee)
      {
          if (type == TicketType.Adult)
          {
              for(int i =0; i &lt; number; i++)
              {
                  tickets.Add(new AdultTicket(show.Title, fee));
              }
          }
              else if (type == TicketType.Child)
              {
                  for(int i=0; i&lt; number; i++)
                  {
                      tickets.Add(new ChildTicket(show.Title));
                   }
              }
          else if (type == TicketType.Family)
          {
              for (int i = 0; i &lt; number; i++)
              {
                  tickets.Add(new FamilyTicket(show.Title, fee));
              }
           }
      }
     
      public string PrintTickets()
      {
          string ticketInfo = &quot;Booking &quot; + bookingID.ToString() + &quot;\n&quot;;
          foreach (ITicket ticket in tickets)
          {
              ticketInfo += ticket.Print();
          }
          return ticketInfo;
      }
  
      public decimal TotalCost()
      {
          decimal totalCost;
          foreach (ITicket ticket in tickets)
          {
              totalCost += ticket.Fee;
          }
          return totalCost;
      }
  
      public override string ToString()
      {
          return string.Format(&quot;{0}: Total Cost={1:c}&quot;, bookingID, TotalCost());
      }
  
  }
  }
  </code></pre>