-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReeferContainer.cs
108 lines (85 loc) · 3.24 KB
/
ReeferContainer.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
namespace APBD_repo_2;
public class ReeferContainer : Container, IHazardNotifier
{
public string ContainerType
{
get => _containerType;
set => _containerType = value ?? throw new ArgumentNullException(nameof(value));
}
private readonly static string CONTAINER_TYPE_CHECK = "C";
private string _containerType;
private double _temperature;
private Product _product;
public Product Product
{
get => _product;
set => _product = value ?? throw new ArgumentNullException(nameof(value));
}
public double Temperature
{
get => _temperature;
set => _temperature = value;
}
public ReeferContainer(double weight, double height, double containerWeight, double depth, double maximumCapacity, string containerType, double temperature) : base(weight, height, containerWeight, depth, maximumCapacity, containerType)
{
Temperature = temperature;
}
public void EmptyTheCargo(Product product)
{
Weight = 0;
Product = product;
Console.WriteLine("You are emptying the cargo. class: " + this.GetType().Name);
Product.Name = String.Empty;
Product.ID = 0;
Product.Temperature = 0;
Product.IsDangerous = false;
//debug
Console.WriteLine();
Console.WriteLine($"{_product.Name} + {_product.ID} + {_product.Temperature} + {_product.IsDangerous}");
Console.WriteLine();
}
public void LoadContainer(double weight, Product product)
{
_product = product;
if (CONTAINER_TYPE_CHECK == _product.TypeOfProduct)
{
if (Temperature >= _product.Temperature)
{
Weight = weight;
}
else
{
Notify(SerialNumber,"Container temperature can't be lower than product expect.");
}
}
if (Weight > MaximumCapacity)
{
throw new OverfillException(
"The cargo weight is bigger than the container maximum capacity. Please try to load less to the one container.");
}
//debug
// Console.WriteLine();
// Console.WriteLine(_product.Name);
// Console.WriteLine();
Console.WriteLine($" Loaded the product {_product.Name} successfully, weight of the product inside container is: {Weight}");
}
public void Notify(string serialNumber, string message)
{
SerialNumber = serialNumber;
Console.WriteLine($"Danger situation happens in: {SerialNumber}: {message}");
}
public void Notify(string serialNumber)
{
SerialNumber = serialNumber;
Console.WriteLine($"Danger situation happens in: {SerialNumber}");
}
public override string GetCargoInfo()
{
return $"Reefer Container - Serial Number: {SerialNumber}, Weight: {Weight}, Temperature: {Temperature}";
}
public override string GetAllVariables()
{
return $" Product Weight: {Weight} kg, Container Height: {Height} cm," +
$" Container Weight: {ContainerWeight} kg, Container Depth: {Depth} cm, Serial Number: {SerialNumber}, Maximum Capacity: {MaximumCapacity} kg, Temperature: {Temperature} (Reefer)";
}
}