-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path30_Person.java
61 lines (40 loc) · 1.05 KB
/
30_Person.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
public class Person {
private String firstName;
private String lastName;
private int age;
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public int getAge(){
return age;
}
public void setFirstName(String firstName){
this.firstName = firstName;
}
public void setLastName(String lastName){
this.lastName = lastName;
}
public void setAge(int age){
if(age < 0 || age > 100)
this.age = 0;
else
this.age = age;
}
public boolean isTeen(){
if(age > 12 && age < 20)
return true;
return false;
}
public String getFullName(){
if(firstName.isEmpty() && lastName.isEmpty())
return "";
if(firstName.isEmpty())
return lastName;
if(lastName.isEmpty())
return firstName;
return firstName + " " + lastName;
}
}