Person.java
1    /* 
2     * A program to model a person in terms of five properties. First name and last name 
3     * (String values), month, day, and year of birth (int values). 
4     */
5    
6    package people;
7    
8    public class Person implements PersonSpecification {
9    
10       private String firstName;
11       private String lastName;
12       private int month;
13       private int day;
14       private int year;
15   
16       public Person(String name, int month, int day, int year) {
17           int space = name.indexOf(" ");
18           String firstName = name.substring(0, space);
19           String lastName = name.substring(space);
20           this.firstName = firstName;
21           this.lastName = lastName;
22           this.month = month;
23           this.day = day;
24           this.year = year;
25       }
26   
27       public String toString() {
28           String representation = "" + firstName + lastName + ", born " + month + "/" + day + "/" + year + "";
29           return representation;
30       }
31   
32       public String firstName() {
33           return firstName;
34       }
35   
36       public String lastName() {
37           return lastName;
38       }
39   
40       public int month() {
41           return month;
42       }
43   
44       public int day() {
45           return day;
46       }
47   
48       public int year() {
49           return year;
50       }
51   
52       public String initials() {
53           String first = firstName.substring(0,1);
54           String last = lastName.substring(1,2);
55           String initials = first.toUpperCase()+last.toUpperCase();
56           return initials;
57       }
58   
59       public boolean isBoomer() {
60           if (year >= 1946) {
61               if (year <= 1964) {
62                   return true;
63               } else {
64                   return false;
65               }
66           }
67           return false;
68       }
69   }
70