47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
/*
|
|
* 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<Client> clients;
|
|
private bool open;
|
|
|
|
public List<Client> Clients { get => clients; set => clients = value; }
|
|
public bool Open { get => open; set => open = value; }
|
|
|
|
public Checkout()
|
|
{
|
|
Clients = new List<Client>();
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|