-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
33 lines (32 loc) · 810 Bytes
/
Person.java
File metadata and controls
33 lines (32 loc) · 810 Bytes
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
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() {
if(age<0||age>100){return 0;}
return age;
}
public void setFirstName(String firstName) {
this.firstName=firstName;
}
public void setLastName(String lastName) {
this.lastName=lastName;
}
public void setAge(int age) {
this.age=age;
}
public boolean isTeen() {
return age > 12 && age < 20;
}
public String getFullName() {
if(firstName==""){return lastName+"";}
if(lastName==""){return firstName+"";}
return (firstName+" "+lastName);
}
}