/* * Rohmer Maxime * STD Project * 25/01/2023 * V1.0 * Checkout.cs * Logic base for the checkout object */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Caisses { internal class Checkout { public const int MAX_CAPACITY = 5; private List clients; private bool open; public List Clients { get => clients; set => clients = value; } public bool Open { get => open; set => open = value; } public Checkout() { Clients = new List(); Open = false; } public void Tick(GraphicalStore store) { //If enough client are waiting or if they wait in average more than the crossover time, we need to open a new checkout. if (!Open && store.AverageWaitingTime > store.CrossoverTime && store.GetEmptyCheckoutCount() == 0 || store.OpenCheckoutCount == 0 || store.WaitingClients.Count > MAX_CAPACITY * 2 && store.GetEmptyCheckoutCount() == 0) { Open = true; } if (Open && store.AverageWaitingTime < 1 && Clients.Count == 0 && store.OpenCheckoutCount > 0) { Open = false; } } } }