/home/rkanin/NetBeansProjects/CS1/src/people/Person.java
 1 /*
 2  * This program will model a person in terms of five properties,
 3  * including the first and last name
 4  */
 5 package people;
 6 
 7 /**
 8  *
 9  * @author rkanin
10  */
11 public class Person implements PersonSpecification {
12     private String firstName;
13     private String lastName;
14     private int month;
15     private int day;
16     private int year;
17     
18     // name --> "Richard Kanin"
19     // name --> George Washington"
20     public Person( String name, int month, int day, int year) {
21          // declare an int variable and bind it to the position of the space in name (use indexOf)
22          // bind firstName to the substring of name from position 0 to one less than the position of the space
23          int startIndex = name.indexOf(" ");
24          this.firstName = name.substring(0,7); // firstName --> "Richard Kanin"
25          // bind lastName to the substring from one more than the position of the space to the end of the string 
26          this.lastName = name.substring(startIndex + 1);  // lastName --> "Richard Kanin"
27          this.month = month;
28          this.day = day;
29          this.year = year;
30         
31             
32     }
33     
34     
35     
36     public String toString(){
37         
38         String name = ( firstName + " " + lastName  + ", "  + "born " + month + "/" + day + "/" + year);
39         return name; 
40         
41     }
42 
43     @Override
44     public String firstName() {
45         return firstName;
46     }
47 
48     @Override
49     public String lastName() {
50         return lastName;
51     }
52 
53     @Override
54     public int month() {
55         return month;
56     }
57 
58     @Override
59     public int day() {
60         return day;
61     }
62 
63     @Override
64     public int year() {
65         return year;
66     }
67 
68     public String initials() {
69          return firstName.substring(0,1) + lastName.substring(0,1);
70     }
71 
72     @Override
73     public boolean isBoomer() {
74         return (year <= 1964 & year >= 1946);
75     }
76 
77     @Override
78     public String intials() {
79         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
80     }
81 
82     
83     
84    
85 }
86