-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeaport.cs
72 lines (59 loc) · 1.74 KB
/
Seaport.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
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace OOP_Project
{
[Serializable][DataContract (Name = "Estado")]
public class Seaport //---- classe para instanciar um objeto que recolha a informação do porto em duas listas
// uma de navios e uma de contentores
{
[DataMember (Name = "Navios")]
public List<Ship> Ships;
[DataMember (Name = "Contentores")]
public List<Container> Containers;
public Seaport()
{
Ships = new List<Ship>();
Containers = new List<Container>();
}
public Seaport(List<Ship> ships, List<Container> containers)
{
Ships = ships;
Containers = containers;
}
public List<Ship> GetShips()
{
return Ships;
}
public void SetShips(List<Ship> ships)
{
Ships = ships;
}
public List<Container> GetContainers()
{
return Containers;
}
public void SetContainers(List<Container> containers)
{
Containers = containers;
}
public override string ToString()
{
string s = Ships.ToString();
string c = Containers.ToString();
return s + c;
}
public override int GetHashCode()
{
return Ships.GetHashCode() + Containers.GetHashCode();
}
public override bool Equals(object obj)
{
if (!(obj is Seaport e)) return false;
bool result =
Ships.Equals(e.Ships) &&
Containers.Equals(e.Containers);
return result;
}
}
}