first commit because I dont want to lose this project
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Caisses
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
public const int MAX_SHOPPING_TIME = 100; //Original 100
|
||||
public const int MIN_SHOPPING_TIME = 10; //Original 10
|
||||
|
||||
public enum ClientState
|
||||
{
|
||||
Shopping,
|
||||
Waiting,
|
||||
Inline,
|
||||
Checkout,
|
||||
}
|
||||
|
||||
private int _shoppingTime;
|
||||
private int _waitingTime;
|
||||
private int _checkoutTime;
|
||||
private ClientState _state;
|
||||
protected static Random Random;
|
||||
public int ShoppingTime
|
||||
{
|
||||
get { return _shoppingTime; }
|
||||
//set { _shoppingTime = value; if (_shoppingTime <= 0) { State = ClientState.Waiting; } }
|
||||
set { _shoppingTime = value; }
|
||||
}
|
||||
public int WaitingTime { get => _waitingTime; set => _waitingTime = value; }
|
||||
public ClientState State { get => _state; set => _state = value; }
|
||||
public int CheckoutTime { get => _checkoutTime; set => _checkoutTime = value; }
|
||||
|
||||
public Client(Random random)
|
||||
{
|
||||
Random = random;
|
||||
ShoppingTime = Random.Next(MIN_SHOPPING_TIME,MAX_SHOPPING_TIME);
|
||||
CheckoutTime = ShoppingTime / 5;
|
||||
State = ClientState.Shopping;
|
||||
}
|
||||
public void Tick()
|
||||
{
|
||||
switch (State)
|
||||
{
|
||||
case ClientState.Shopping:
|
||||
ShoppingTime -= 1;
|
||||
if (ShoppingTime <= 0)
|
||||
{
|
||||
State = ClientState.Waiting;
|
||||
}
|
||||
break;
|
||||
case ClientState.Waiting:
|
||||
WaitingTime += 1;
|
||||
break;
|
||||
case ClientState.Inline:
|
||||
//We dont do anything when he is in a checkoutLine
|
||||
break;
|
||||
case ClientState.Checkout:
|
||||
CheckoutTime -= 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user