-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
53 lines (44 loc) · 937 Bytes
/
Copy pathPerson.java
File metadata and controls
53 lines (44 loc) · 937 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.time.*;
public class Person
{
private String firstName;
private String lastName;
private LocalDate birthday;
public Person()
{
this.firstName = null;
this.lastName = null;
birthday = null;
System.out.println("Default Person Constructor");
}
public Person(String fName, String lName)
{
this.firstName = fName;
this.lastName = lName;
birthday = LocalDate.now();
}
public void setBirthday(int year, int month, int day)
{
this.birthday = LocalDate.of(year, month, day);
}
public String getName()
{
if(firstName==null||lastName==null)
return null;
return firstName+" "+lastName;
}
public String getBirthday()
{
if(birthday == null)
return null;
return birthday.toString();
}
public String toString()
{
return "PERSON: "+getName()+" "+getBirthday();
}
public void greeting()
{
System.out.println("Hello, my name is "+this.firstName+".\n\tI am a person.");
}
}