Aplicación de consola Bankteller
Estoy haciendo una aplicación simple para simular elproblema de cajero. Lo que intento simular es:
Tienes 4 mostradores en una tienda. 1 mostrador está abierto. Los clientes comienzan a ingresar y entran en la línea para el primer contador.
Cuando el cuarto cliente ingresa a la línea para el primer contador, se debe abrir otro contador. La línea debe dividirse en partes iguales entre los 2 contadores. Cuando se ayuda al cliente en el segundo mostrador y no entran nuevos clientes, el contador debe cerrarse. Básicamente 4 es demasiado.
Parece que no puedo entenderlo. Sé que necesito usar una cola. ¿Pero cómo? ¿Podría alguien darme un ejemplo en la aplicación de consola? Preferible C #.
Gracias por adelantado.
Esto es lo que intenté hasta ahora
clase de registro:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RegisterCounter
{
class Register
{
private int customerCount;
public Queue<Customer> Line = new Queue<Customer>();
public Register()
{
customerCount = 2;
}
public Register(int customerCount)
{
this.customerCount = customerCount;
}
public int getCustomers()
{
return customerCount;
}
}
}
Clase de cliente:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RegisterCounter
{
class Customer
{
private int checkoutTime;
public Customer()
{
checkoutTime = 3;
}
public Customer(int checkoutTime)
{
this.checkoutTime = checkoutTime;
}
public int GetCheckoutTime()
{
return checkoutTime;
}
}
}
Gerente de registro:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RegisterCounter
{
class RegisterManager
{
public List<Register> registers = new List<Register>();
Register r1 = new Register();
Customer c1 = new Customer();
public RegisterManager()
{
registers.Add(r1);
}
public void ManageCustomers()
{
for (int i = 0; i < registers.Count; i++)
{
registers.Insert(i, new Register());
if (i / 4 <= registers..Line.Count)
{
}
}
}
}
}