-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMobilePhone.java
66 lines (52 loc) · 1.44 KB
/
MobilePhone.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
public class MobilePhone
{
private int number;
private boolean pstatus;
private Exchange baseStation;
public MobilePhone(int number)
{
this.number = number;
pstatus=false;
}
public int getId()
{
return number;
}
// – public Int number(): returns the id of the mobile phone.
public int number()
{
return this.number;
}
// – public Boolean status(): returns the status of the phone, i.e. switched on or switched off.
public boolean status()
{
return pstatus;
}
// – public void switchOn(): Changes the status to switched on
public void switchOn()
{
pstatus = true;
}
// – public void switchOff(): Changes the status to switched off.
public void switchOff()
{
pstatus = false;
}
// – public Exchange location(): returns the base station with which the phone is registered if the phone is switched on
// and an exception if the phone is off. The class Exchange will be described next.
public Exchange location()
{
// if(pstatus)
// {
return baseStation;
// }
// else
// {
// throw new Exception("phone is off");
// }
}
public void setBase(Exchange base)
{
baseStation = base;
}
}