parseDate("06/19/1623"),
Occupation.SCIENTIST));
addCelebrity(new Celebrity("Isaac", "Newton",
Formats.parseDate("01/04/1643"),
Occupation.SCIENTIST));
addCelebrity(new Celebrity("Antonio", "Vivaldi",
Formats.parseDate("03/04/1678"),
Occupation.COMPOSER));
addCelebrity(new Celebrity("Niccolo", "Paganini",
Formats.parseDate("10/27/1782"),
Occupation.MUSICIAN));
addCelebrity(new Celebrity("Johannes", "Kepler",
Formats.parseDate("12/27/1571"),
Occupation.SCIENTIST));
addCelebrity(new Celebrity("Franz", "Kafka",
Formats.parseDate("07/03/1883"),
Occupation.WRITER));
addCelebrity(new Celebrity("George", "Gershwin",
Formats.parseDate("09/26/1898"),
Occupation.COMPOSER));
}
public List
getAllCelebrities()
{
return celebrities;
}
public Celebrity getCelebrityById(long id)
{
for (Celebrity c : celebrities)
{
if (c.getId() == id) return c;
}
return null;
}
public void addCelebrity(Celebrity c)
{
long newId = celebrities.size();
c.setId(newId);
celebrities.add(c);
}
}
Simple Components
[ 86 ]
Please add such a class to the com.packtpub.celebrities.data package. You can
see a utility class??”Formats, used in it to simplify conversion between dates and
strings.
Pages:
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122