31 lines
1.2 KiB
Markdown
31 lines
1.2 KiB
Markdown
|
The next exercises will focus around simulating a supermarket with multiple customers and multiple queues.
|
||
|
In contrast to the lift-course we will not simulate a fixed amount of time. Instead we will simulate
|
||
|
until all customers are served.
|
||
|
|
||
|
## Model
|
||
|
|
||
|
As with the lift we will take tiny steps and will increase the complexity of the model bit by bit.
|
||
|
Our end goal is to have a bunch of customers with different items, which all take different amounts of time to scan,
|
||
|
which will be served by multiple cashiers.
|
||
|
|
||
|
To get there we start with only one customer and one cashier. Each item should take the same amount of time.
|
||
|
To do that, we keep track of the item count in the Variable ``CustomerItemCount``.
|
||
|
When one gets processed we simply need do decrement that value.
|
||
|
|
||
|
## Knowledge
|
||
|
|
||
|
Because we don't want a fixed amount of time steps, like we did with the lift, we need a different kind of _loop_.
|
||
|
A **while-loop** loops as long as its condition is true.
|
||
|
|
||
|
while(condition)
|
||
|
{
|
||
|
// looped code here
|
||
|
}
|
||
|
|
||
|
This is exactly what we need to serve all customers until no one is left or for now until all items are gone.
|
||
|
|
||
|
## Task
|
||
|
|
||
|
For now your task will be to implement one cashier and one customer with 5 items.
|
||
|
Each item should take the same amount of time for now.
|