|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlabtest1.President
public class President
This class represents a president. There can be only a single president (singleton).
Method Summary | |
---|---|
String |
getFirstName()
Returns the first name of this president. |
static President |
getInstance(String firstName,
String lastName)
Returns a president with the given first name, last name and no years in office. |
static President |
getInstance(String firstName,
String lastName,
int numberOfYearsInOffice)
Returns a president with the given first name, last name and number of years in office. |
String |
getLastName()
Returns the last name of this president. |
String |
getName()
Returns the name of this president. |
int |
getNumberOfYearsInOffice()
Returns the number of years in office of this president. |
void |
setNumberOfYearsInOffice(int numberOfYearsInOffice)
Sets the number of years in office of this president to the given number of years in office. |
String |
toString()
Returns a string representation of this president. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public String getFirstName()
public String getLastName()
public int getNumberOfYearsInOffice()
public void setNumberOfYearsInOffice(int numberOfYearsInOffice)
numberOfYearsInOffice
- the new number of years in office
of this president.public String getName()
public static President getInstance(String firstName, String lastName, int numberOfYearsInOffice)
firstName
- the first name of the president.lastName
- the last name of the president.numberOfYearsInOffice
- the number of years in office.public static President getInstance(String firstName, String lastName)
firstName
- the first name of the president.lastName
- the last name of the president.
public String toString()
toString
in class Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |