Пример #1
0
 public Standard()
 {
     Name         = "Sala estándar";
     Columns      = 8;
     Rows         = 8;
     tickets      = new MovieTicket[Rows, Columns];
     ActualColumn = 0;
     ActualRow    = 0;
     Price        = 3.55;
 }
Пример #2
0
 public void AddTicket(MovieTicket ticket)
 {
     tickets[ActualRow, ActualColumn] = ticket;
     ActualColumn++;
     if (ActualColumn == Columns)
     {
         ActualColumn = 0;
         ActualRow++;
     }
 }
Пример #3
0
 public DriveIn()
 {
     Name         = "AutoCine";
     Columns      = 50;
     Rows         = 50;
     tickets      = new MovieTicket[Rows, Columns];
     ActualColumn = 0;
     ActualRow    = 0;
     Price        = 8.25;
 }
Пример #4
0
 public VIP()
 {
     Name         = "Sala VIP";
     Columns      = 6;
     Rows         = 5;
     tickets      = new MovieTicket[Rows, Columns];
     ActualColumn = 0;
     ActualRow    = 0;
     Price        = 6.50;
 }
Пример #5
0
 public Premium()
 {
     Name         = "Sala premium";
     Columns      = 8;
     Rows         = 5;
     tickets      = new MovieTicket[Rows, Columns];
     ActualColumn = 0;
     ActualRow    = 0;
     Price        = 4.75;
 }
Пример #6
0
        public string PrintSeats(MovieTicket ticket)
        {
            StringBuilder str = new StringBuilder();

            for (int i = 0; i < Rows; i++)
            {
                for (int j = 0; j < Columns; j++)
                {
                    if (tickets[i, j] == ticket)
                    {
                        str.Append(string.Format("{0}-{1} ", Program.AbecedaryRepo[j], i + 1));
                    }
                }
            }
            return(str.ToString());
        }
Пример #7
0
            public static void Option3()
            {
                Console.Clear();
                Console.WriteLine("-----> Comprar Boletos <-----\n");
                Console.Write("\nIngrese el ID de la pelicula a comprar: ");
                Movie movie = ExistMovie(Console.ReadLine());

                if (movie != null)
                {
                    double subtotal = 0;
                    double total;
                    Console.WriteLine("Pelicula Elegida");
                    Console.WriteLine("---------------------------------");
                    Console.WriteLine("ID Pelicula: {0}", movie.ID);
                    Console.WriteLine("Titulo de la Pelicula: {0}", movie.Title);
                    Console.WriteLine("Duración de la película: {0}", movie.Duration);
                    Console.WriteLine("Tipo de la película: {0}", movie.Type);
                    Console.WriteLine("---------------------------------");
                    Console.WriteLine("\nSucursales: ");
                    if (BranchData.officeBranches.Count == 0)
                    {
                        Console.WriteLine("No existen sucursales disponibles en este momento.");
                        return;
                    }
                    foreach (Branch office in BranchData.officeBranches)
                    {
                        Console.WriteLine("--------------------------------");
                        Console.WriteLine("ID de la sucursal: {0}", office.ID);
                        Console.WriteLine("Nombre de la sucursal: {0}", office.Name);
                        Console.WriteLine("--------------------------------");
                    }
                    Branch selectOffice = null;
                    Console.Write("Ingrese el ID de la sucursal: ");
BranchAgain:
                    string bID = Console.ReadLine();
                    foreach (Branch office in BranchData.officeBranches)
                    {
                        if (office.ID == bID)
                        {
                            selectOffice = office;
                            break;
                        }
                    }
                    if (selectOffice == null)
                    {
                        Console.WriteLine("Sucursal no encontrada. Ingrese nuevamente el ID: ");
                        goto BranchAgain;
                    }
                    Console.WriteLine("\nSalas de exhibición:");
                    Console.WriteLine(" 1 - Estándar\n");
                    Console.WriteLine(" 2 - Premium\n");
                    Console.WriteLine(" 3 - VIP\n");
                    Console.WriteLine(" 4 - Autocine\n");
                    Console.Write("\nIngrese una opcion deseada: ");
                    do
                    {
                        validateOption();
                        if (option < 1 || option > 4)
                        {
                            Console.WriteLine("Ingrese una opcion correcta: ");
                        }
                    } while (option < 1 || option > 4);
                    Console.Write("\nIngrese la cantidad de boletos a comprar: ");
                    int numOfTickets;
                    do
                    {
                        while (!Int32.TryParse(Console.ReadLine(), out numOfTickets))
                        {
                            Console.Write("\nIngrese una cantidad válida: ");
                        }
                        if (numOfTickets <= 0)
                        {
                            Console.Write("\nDebe ingresar una cantidad mayor a 0: ");
                        }
                    } while (numOfTickets <= 0);
                    bool  space = true;
                    Rooms room  = null;
                    switch (option)
                    {
                    case 1:
                        room = Program.stdRoom;
                        break;

                    case 2:
                        room = Program.premRoom;
                        break;

                    case 3:
                        room = Program.vipRoom;
                        break;

                    case 4:
                        room = Program.driveIn;
                        break;
                    }
                    if (option != 4)
                    {
                        space = room.ValidateSpaces(numOfTickets);
                    }
                    else
                    {
                        space = true;
                    }
                    if (space)
                    {
                        MovieTicket ticket = new MovieTicket();
                        ticket.ID = string.Format("T{0,0:D4}", Billboard.ticketIdentity);
                        Billboard.ticketIdentity++;
                        ticket.MovieName    = movie.Title;
                        ticket.TheatherName = "KODI-MAX";
                        ticket.Room         = room;
                        subtotal            = room.Price * numOfTickets;
                        ticket.Date         = DateTime.Now;
                        ticket.branch       = selectOffice;
                        Random rdn            = new Random();
                        int    countEmployees = 0;
                        foreach (User user in UserRepository.Users)
                        {
                            if (Convert.ToChar(user.UserID.Substring(0, 1)) == 'E')
                            {
                                countEmployees++;
                            }
                        }
                        if (countEmployees == 0)
                        {
                            ticket.EmployeeID   = "V0000";
                            ticket.EmployeeName = "Empleado Virtual";
                        }
                        else
                        {
                            int random        = rdn.Next(1, countEmployees + 1);
                            int countToSelect = 0;
                            foreach (User user in UserRepository.Users)
                            {
                                if (Convert.ToChar(user.UserID.Substring(0, 1)) == 'E')
                                {
                                    countToSelect++;
                                    if (countToSelect == random)
                                    {
                                        ticket.EmployeeID   = user.UserID;
                                        ticket.EmployeeName = user.Name;
                                        break;
                                    }
                                }
                            }
                        }
                        for (int i = 0; i < numOfTickets; i++)
                        {
                            room.AddTicket(ticket);
                        }
                        double tax        = Math.Round(subtotal * 0.3533, 2);
                        double optPayment = 0;
                        total = Math.Round(subtotal + tax, 2);
                        Console.WriteLine("\n\n>Impresión del ticket<");
                        Console.WriteLine("------------------------------------------------------------------");
                        Console.WriteLine("Nombre del cine: {0}", ticket.TheatherName);
                        Console.WriteLine("Nombre del empleado que lo atendió: {0}", ticket.EmployeeName);
                        Console.WriteLine("ID del empleado que lo atendió: {0}", ticket.EmployeeID);
                        Console.WriteLine("Fecha y hora de compra: {0}", ticket.Date);
                        Console.WriteLine("Nombre de la pelicula: {0}", ticket.MovieName);
                        Console.WriteLine("Nombre de la sucursal: {0}", ticket.branch.Name);
                        if (option == 4)
                        {
                            Console.WriteLine("Modalidad: Autocine");
                            Console.WriteLine("Precio de parqueo: $1.50");
                            optPayment = 1.50;
                        }
                        else
                        {
                            Console.WriteLine("Modalidad: Sala normal");
                            Console.WriteLine("Sala: {0}", ticket.Room.Name);
                            Console.WriteLine("Asientos: {0}", room.PrintSeats(ticket));
                        }
                        Console.WriteLine("Subtotal: ${0}", Math.Round(subtotal, 2) + optPayment);
                        Console.WriteLine("Impuesto aplicado (35.33%): ${0}", tax);
                        Console.WriteLine("Total: ${0}", total);
                        Console.WriteLine("------------------------------------------------------------------");
Again:
                        Console.Write("\n\nIngrese el efectivo: $");
                        double payment;
                        do
                        {
                            while (!Double.TryParse(Console.ReadLine(), out payment))
                            {
                                Console.Write("Ingrese una cantidad válida: $");
                            }
                            if (payment < 0)
                            {
                                Console.Write("Ingrese una cantidad válida: $");
                            }
                        } while (payment < 0);

                        if (payment == total)
                        {
                            Console.WriteLine("Cobro exacto, gracias por comprar en KODIMAX.");
                        }
                        else if (payment > total)
                        {
                            Console.WriteLine("Su cambio es ${0}, gracias por comprar en KODIMAX", Math.Round(payment - total, 2));
                        }
                        else
                        {
                            Console.WriteLine("Pago insuficiente");
                            goto Again;
                        }
                    }
                    else
                    {
                        Console.WriteLine("\nNo hay espacio suficiente en la sala para efectuar su compra.");
                    }
                }
                else
                {
                    Console.WriteLine("El ID de pelicula ingresado no existe");
                }
            }