-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExchange.java
85 lines (73 loc) · 1.15 KB
/
Exchange.java
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
import java.util.*;
public class Exchange
{
int id;
Exchange parent;
ExchangeList children;
MobilePhoneSet residentSet;
public Exchange(int number)
{
id = number;
parent = null;
children = new ExchangeList();
residentSet = new MobilePhoneSet();
}
public boolean equals(Exchange e)
{
if(this == e) return true;
if(e == null) return false;
return (id == e.id);
}
public Exchange parent()
{
return parent;
}
public int numChildren()
{
return children.size();
}
public Exchange child(int i)
{
try
{
return children.getMember(i);
}
catch(RuntimeException e)
{
throw e;
}
}
public boolean isRoot()
{
return (parent == null);
}
public void addChild(Exchange e)
{
children.Insert(e);
}
public int[] getMobiles()
{
return residentSet.getMobiles();
}
public MobilePhone getMobile(int m)
{
return residentSet.getMobile(m);
}
public RoutingMapTree subtree(int i)
{
RoutingMapTree tree = new RoutingMapTree();
try
{
tree.root = this.child(i);
return tree;
}
catch(RuntimeException e)
{
throw e;
}
}
public MobilePhoneSet residentSet()
{
return residentSet;
}
}