-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContainer.cs
108 lines (88 loc) · 2.58 KB
/
Container.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
using System;
using System.Runtime.InteropServices.ComTypes;
using System.Runtime.Serialization;
namespace OOP_Project
{
[Serializable][DataContract (Name = "Contentor")]
[KnownType(typeof(Regular))]
[KnownType(typeof(Explosive))]
[KnownType(typeof(Chemical))]
public abstract class Container //---- super-classe de contentores
{
[DataMember (Name = "Numero Navio")]
protected int ShipNumber;
[DataMember (Name = "Numero")]
protected string Number;
[DataMember (Name = "Destino")]
protected string Destination;
[DataMember (Name = "Peso")]
protected int Weight;
public int GetShipNumber()
{
return ShipNumber;
}
public void SetShipNumber(int shipNumber)
{
ShipNumber = shipNumber;
}
public string GetNumber()
{
return Number;
}
public void SetNumber(string number)
{
Number = number;
}
public string GetDestination()
{
return Destination;
}
public void SetDestination(string destination)
{
Destination = destination;
}
public int GetWeight()
{
return Weight;
}
public void SetWeight(int weight)
{
Weight = weight;
}
protected string ContainerNumber()
{
char a, b, c, d;
int num1, num2;
string cNumb;
var random = new Random();
a = (char)random.Next(65, 90);
b = (char)random.Next(65, 90);
c = (char)random.Next(65, 90);
d = (char)random.Next(65, 90);
num1 = random.Next(100000, 999999);
num2 = random.Next(1, 9);
cNumb = a.ToString() + b.ToString() + c.ToString() + d.ToString() + " " + num1 + " " + num2;
return cNumb;
}
public override string ToString()
{
string s;
s = "\t\tNúmero de contentor: " + Number + "\t Destino: " + Destination + "\t Peso: " + Weight;
if (ShipNumber != -1)
{
s += "\n\t\tNavio: " + ShipNumber;
}
s += "\n\t\t\t------------------";
return s;
}
public override int GetHashCode()
{
return Number.GetHashCode();
}
public override bool Equals(object obj)
{
if (!(obj is Container c)) return false;
return Number == c.Number;
}
}
}