Exemple #1
0
        public void AddShowTime(Theater theater, Movie movie, string time)
        {
            if (!Showtimes.ContainsKey(movie))
            {
                Showtimes.Add(movie, new List <Showtime>());
            }
            var showTime = new Showtime()
            {
                Movie   = movie,
                Time    = time,
                Theater = theater,
                Tickets = new List <Ticket>()
            };

            for (var i = 0; i < theater.Seats; i++)
            {
                showTime.Tickets.Add(new Ticket()
                {
                    Seat     = "A" + (i + 1),
                    Cinema   = this,
                    Theater  = theater,
                    Movie    = movie,
                    Showtime = showTime
                });
            }

            Showtimes[movie].Add(showTime);
        }
Exemple #2
0
 private void MakeTickets(Showtime showtime)
 {
     for (var i = 0; i < showtime.Theater.Capacity; i++)
     {
         showtime.Theater.Tickets.Add(new Ticket()
         {
             Showtime   = showtime,
             Price      = DefaultTicketPrice,
             SeatNumber = i + 1
         });
     }
 }
Exemple #3
0
        public void CreateShowtime(Theater theater, Movie movie, string time)
        {
            var newShowtime = new Showtime()
            {
                Cinema  = this,
                Theater = theater,
                Movie   = movie,
                Time    = time
            };

            Showtimes.Add(newShowtime);
            MakeTickets(newShowtime);
        }
Exemple #4
0
        public void ShowAvailableTickets(Showtime showtime)
        {
            System.Console.WriteLine($@"
-----------------------------------------------------
| Price | Seat |
------------------------------------------------------");
            showtime.Theater.Tickets.ForEach(ticket =>
            {
                if (!ticket.Purchased)
                {
                    System.Console.WriteLine($@"
${ticket.Price} | {ticket.SeatNumber}");
                }
            });
        }