1 /* 2 *This program will model a person in terms of five properties: 3 * First Name and Last Name (STRING Value) 4 * Month, Day, and Year of Birth (INT Value) 5 * 6 * this code is using the methods that were defined 7 * only implement interfaces to classes 8 */ 9 10 package people; 11 12 public class Person implements PersonSpecification { 13 14 //INSTANCE VARIABLES 15 private String firstName; 16 private String lastName; 17 private int month; 18 private int day; 19 private int year; 20 21 //CONSTRUCTOR 22 //First name and Last name are defined as name but are differentiate by using substring 23 public Person(String name, int month, int day, int year) { 24 int spacePosition = name.indexOf(" "); 25 this.firstName = name.substring(0, spacePosition); 26 this.lastName = name.substring(spacePosition + 1); 27 this.month = month; 28 this.day = day; 29 this.year = year; 30 } 31 32 33 //displays the name and birthday of all people 34 //toString Method 35 public String toString() { 36 return (firstName + " " + lastName) + "," + month + "|" + day + "|" + year; 37 } 38 39 40 @Override 41 public String firstName() { 42 return firstName; 43 } 44 45 @Override 46 public String lastName() { 47 return lastName; 48 } 49 50 @Override 51 public int month() { 52 return month; 53 } 54 55 @Override 56 public int day() { 57 return day; 58 } 59 60 @Override 61 public int year() { 62 return year; 63 } 64 65 @Override 66 public String initials() { 67 String firstNameFirstLetter = firstName.substring(0, 1); 68 String lastNameFirstLetter = lastName.substring(0, 1); 69 String initials = firstNameFirstLetter + lastNameFirstLetter; 70 return initials; 71 } 72 73 @Override 74 public boolean isBoomer() { 75 if (1946 <= year & year <= 1964) { 76 return true; 77 } else 78 return false; 79 80 } 81 } 82 83