-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExchange.java
46 lines (45 loc) · 1.01 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
public class Exchange
{
int id;
Exchange parent;
Exchange next;
ExchangeList children;
MobilePhoneSet registeredMobiles;
Exchange(int number){
id=number;
next=null;
children=new ExchangeList();
registeredMobiles=new MobilePhoneSet();
}
public void setParent(Exchange l){
this.parent=l;
}
public Exchange parent(){
return parent;
}
public int numChildren(){
return children.countChildren();
}
public Boolean isRoot(){
if(parent==null)
return true;
else
return false;
}
public Exchange child(int i)throws Exception{
if(i>this.numChildren())
throw new Exception("Enter i within 0 to number of children");
else
return children.specificChild(i);
}
public RoutingMapTree subtree(int i)throws Exception
{
if(i>this.numChildren())
throw new Exception("Enter i within 0 to number of children");
else
return new RoutingMapTree(children.specificChild(i));
}
public MobilePhoneSet residentSet(){
return registeredMobiles;
}
}