Person.java
1    /* 
2    * program to model a person in terms of five properties 
3    * first name, last name(string) , month ,day, and year of birth (int) 
4     */
5    
6    
7    package people;
8    
9    
10   public class Person implements PersonSpecification {
11   
12       //Instance variables
13       private String firstName;
14       private String lastName;
15       private int month;
16       private int day;
17       private int year;
18   
19   
20   
21       //Define a constructor
22       public Person(String name,int month,int day,int year) {
23           int space = name.indexOf(" ");
24           this.firstName = name.substring(0,space);
25           this.lastName = name.substring(space);
26           this.month = month;
27           this.day = day;
28           this.year = year;
29   
30   }
31       public String toString() {
32           return   firstName + lastName +", born " + month + "/" + day + "/" + year;
33       }
34   
35       @Override
36       public String firstName() {
37           return firstName;
38       }
39   
40       @Override
41       public String lastName() {
42           return lastName;
43       }
44   
45       @Override
46       public int month() {
47           return month;
48       }
49   
50       @Override
51       public int day() {
52           return day;
53       }
54   
55       @Override
56       public int year() {
57           return year;
58       }
59   
60       @Override
61       public String initials() {
62           String firstLetter = firstName.substring(0,1);
63           String firstLetterLast = lastName.substring(1,2);
64           firstLetter = firstLetter.toUpperCase();
65           firstLetterLast = firstLetterLast.toUpperCase();
66           return firstLetter + firstLetterLast;
67       }
68   
69       @Override
70       public boolean isBoomer() {
71           //1946-1964
72           //It's tempting to write an expression like "10 < X < 20" to see
73           // if X is between 10 and 20.
74           // That does not work.
75           // Each "<" operator must get its own two values.
76           // So the correct way to write it is: "10<X && X<20".
77           // https://codingbat.com/doc/java-if-boolean-logic.html
78           if (year<=1964 && year>=1946) {
79               return true;
80           } else { return false; }
81           }
82       }
83   
84