1 package people; 2 3 /* 4 * This program will model a person in terms of five properties 5 * first name 6 * last name 7 * month of birth 8 * day of birth 9 * year of birth 10 */ 11 12 public class Person implements PersonSpecification { 13 //INSTANCE VARIABLES 14 private String firstName; 15 private String lastName; 16 private int month; 17 private int day; 18 private int year; 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); 24 this.month = month; 25 this.day = day; 26 this.year = year; 27 28 } 29 30 public String toString() { 31 String display = firstName + " " + lastName + ", born " + month + "/" + day + "/" + year; 32 return display; 33 } 34 35 public String firstName() { 36 return firstName; 37 } 38 39 public String lastName() { 40 return lastName; 41 } 42 43 44 public int month() { 45 return month; 46 } 47 48 49 public int day() { 50 return day; 51 } 52 53 54 public int year() { 55 return year; 56 } 57 58 59 public String initials() { 60 char firstInitial = firstName.charAt(0); 61 char lastInitial = lastName.charAt(0); 62 String initials = Character.toString(firstInitial).toUpperCase() + Character.toString(lastInitial).toUpperCase(); 63 return initials; 64 } 65 66 67 //according to the internet, boomers were born between 1946 and 1964 68 public boolean isBoomer() { 69 if (year > 1945 && year < 1965) { 70 return true; 71 } else { 72 return false; 73 } 74 } 75 }