-
Notifications
You must be signed in to change notification settings - Fork 0
/
BloodSupply.cs
46 lines (44 loc) · 1.75 KB
/
BloodSupply.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
namespace Symulacja_Cyfrowa
{
class BloodSupply : Event
{
private int _eventTime;
private string _type;
private int _bUnits;
private bool _flagEmergency;
public BloodSupply(int eventTime, string type, int bUnits,bool flagEmergency) : base(eventTime, type)
{
_eventTime = eventTime;
_type = Type;
_bUnits = bUnits; // Blood units N = 20 / Q = 11
_flagEmergency = flagEmergency;
}
public int BUnits
{
get { return _bUnits; }
set { _bUnits = BUnits; }
}
public override void Execute(List<Event> scheduler, BloodStore bloodStorage, PatientQueue patientQ)
{
_type = "BT";
int time = BUnits == 1 ? 500 : 300; // lambda statemenet N and Q are connect with T1 and T2
for(int i=0; i<BUnits; i++)
{
bloodStorage.BloodLevel++;
bloodStorage.BloodStorageList.Add(new Blood(time));
Utilisation temp = new Utilisation(SystemTime + time, "aUT");
AddToScheduler(scheduler, temp); // Adds time of utilisation of Blood
if (_flagEmergency == true) // Enables to return exactly right units of blood from Emergency
{
temp.BloodFromEmergency = true;
}
}
BloodStore.Sorted(bloodStorage.BloodStorageList);
Sorted(scheduler);
if(time == 300) { BloodStore.OrderFlag = false; } // Setting right flags (makes NewOrder available)
else{ BloodStore.EmergencyFlag = false; } // Makes EmergencyOrder available
}
}
}