A02_Codes/LocalUser.java
A02_Codes/LocalUser.java
package
info
.
razib
.
edu
;
public
class
LocalUser
extends
PolicyUser
{
// Subclass
// Inheritance gives LocalUser all the same fields and methods as PolicyUser
// yet allows its code to focus exclusively on the features that make it unique.
// Every class has one and only one direct superclass (i.e. single inheritance)
String
userCategory
;
public
LocalUser
(
String
userId
,
int
MCC
,
int
MNC
)
{
super
(
userId
,
MCC
,
MNC
);
userCategory
=
"prepaid"
;
}
public
boolean
setUserService
(){
if
(
this
.
MCC
==
1
&&
this
.
MNC
==
70
){
this
.
service
=
true
;
return
true
;
}
return
false
;
}
public
String
getUserCategory
(){
if
(
this
.
userId
.
startsWith
(
"322"
)){
return
this
.
userCategory
;
}
else
{
this
.
userCategory
=
"postpaid"
;
return
this
.
userCategory
;
}
}
public
static
void
printUserDetails
(){
// changed signature
System
.
out
.
println
(
"This is a test message inside LocalUser class"
);
}
}
A02_Codes/PolicyUser.java
A02_Codes/PolicyUser.java
package
info
.
razib
.
edu
;
public
class
PolicyUser
{
// This is our Super Class
String
userId
,
SessionId
;
int
MCC
,
MNC
;
boolean
service
;
public
PolicyUser
(){
userId
=
"u000"
;
SessionId
=
"s000"
;
MCC
=
1
;
MNC
=
909
;
service
=
false
;
}
public
PolicyUser
(
String
userId
,
int
MCC
,
int
MNC
){
this
();
this
.
userId
=
userId
;
this
.
MCC
=
MCC
;
this
.
MNC
=
MNC
;
}
public
String
getSessionId
(){
return
SessionId
;
}
public
String
getUserId
(){
return
userId
;
}
public
int
getMCC
(){
return
MCC
;
}
public
int
getMNC
(){
return
MNC
;
}
public
static
void
printUserDetails
(){
System
.
out
.
print
(
"This is a test message inside PolicyUser class\r"
);
}
}
A02_Codes/RoamingUser.java
A02_Codes/RoamingUser.java
package
info
.
razib
.
edu
;
public
class
RoamingUser
extends
PolicyUser
{
public
RoamingUser
(
String
userId
,
int
MCC
,
int
MNC
)
{
super
(
userId
,
MCC
,
MNC
);
}
public
boolean
setUserService
(){
if
(
this
.
MCC
==
1
&&
((
this
.
MNC
==
12
)
||
(
this
.
MNC
==
120
))){
this
.
service
=
true
;
return
true
;
}
return
false
;
}
}