|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectPerson
The class Person
represents a person having a name and
address. The name and address are represented as strings. There is
a method that allows changing the address, but the name cannot be changed.
Constructor Summary | |
Person()
The default constructor initializes a person named "John Doe" in "New York City" |
|
Person(java.lang.String n,
java.lang.String a)
This is the constructor that would normally be used to create a Person object. |
Method Summary | |
java.lang.String |
getAddress()
The accessor function getAddress returns the person's address. |
java.lang.String |
getName()
The accessor function getName returns the person's name. |
void |
setAddress(java.lang.String a)
Sets the person's address. |
java.lang.String |
toString()
Returns a string representing the person, consisting of the name followed by "/" followed by the address. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Person()
public Person(java.lang.String n, java.lang.String a)
Person
object. It initializes the name and address
from the calling parameters.
n
- the person's namea
- the person's addressMethod Detail |
public java.lang.String getName()
getName
returns the person's name.
Pre-condition: None.
Post-condition: Returns the name.
public java.lang.String getAddress()
getAddress
returns the person's address.
Pre-condition: None.
Post-condition: Returns the address.
public void setAddress(java.lang.String a)
Pre-condition: None.
Post-condition: Changes the address.
a
- the person's addresspublic java.lang.String toString()
Pre-condition: None.
Post-condition: Returns a string name + "/" + address
.
name + "/" + address
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |