1 /* 2 * A person in this context will be modelled in terms of five properties: first name, last name, month , day, 3 * and year of birth. 4 */ 5 6 package people; 7 8 public class Person implements PersonSpecification { 9 10 // THE INSTANCE VARIABLES 11 12 private String firstName; 13 private String lastName; 14 private int month; 15 private int day; 16 private int year; 17 18 // THE CONSTRUCTOR 19 20 public Person(String name, int month, int day, int year) { 21 int space = name.indexOf(" "); 22 firstName = name.substring(0, space); 23 lastName = name.substring(space + 1, name.length()); 24 this.month = month; 25 this.day = day; 26 this.year = year; 27 } 28 29 //THE METHODS 30 31 public String toString() { 32 String introduction = firstName + " " + lastName+ ", born " + month + "/" + day + "/" + year; 33 return introduction; 34 35 } 36 37 38 @Override 39 public String firstName() { 40 return firstName; 41 } 42 43 @Override 44 public String lastName() { 45 return lastName; 46 } 47 48 @Override 49 public int month() { 50 return month; 51 } 52 53 @Override 54 public int day() { 55 return day; 56 } 57 58 @Override 59 public int year() { 60 return year; 61 } 62 63 @Override 64 public String initials() { 65 String fi = firstName.substring(0,1); 66 String li = lastName.substring(0,1); 67 String initials = fi+li; 68 return initials; 69 } 70 71 @Override 72 public boolean isBoomer() { 73 if (year >= 1946) { 74 if (year <= 1964){ 75 return true; 76 } 77 } else { 78 return false; 79 } 80 return false; 81 } 82 83 } 84 85