|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Person
A Person object can communicate with other Persons.
The Person can send and receive simple textual messages.
The person can change his status to ONLINE, OFFLINE, BUSY or INVISIBLE.
Field Summary | |
static int |
BUSY
|
static int |
INVISIBLE
|
static int |
OFFLINE
|
static int |
ONLINE
|
Constructor Summary | |
Person(java.lang.String name)
Creates a new person. |
Method Summary | |
java.lang.String |
getName()
Returns the name of the person |
boolean |
receiveMessage(Person peer,
java.lang.String message)
Receives a message from a peer. |
boolean |
sendMessage(Person peer,
java.lang.String message)
Attempts to send a message to a peer. |
void |
setStatus(int status)
Changes the status of the person. |
void |
setStatus(java.lang.String status)
Changes the status of the person. |
java.lang.String |
toShortString()
Returns a single line representation of the person. |
java.lang.String |
toString()
Returns a String representation of the person. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final int ONLINE
public static final int OFFLINE
public static final int BUSY
public static final int INVISIBLE
Constructor Detail |
public Person(java.lang.String name)
A new person is ONLINE.
name
- The nane of the new perosn.Method Detail |
public void setStatus(int status)
The status can be either: ONLINE, OFFLINE, BUSY, INVISIBLE.
status
- The new status of the person.public void setStatus(java.lang.String status)
The status is one of the Strings: ONLINE, OFFLINE, BUSY, INVISIBLE
status
- The new status of the person.public boolean sendMessage(Person peer, java.lang.String message)
peer
- The Person who will receive the message.message
- The message to be sent.public boolean receiveMessage(Person peer, java.lang.String message)
If the message can be displayed (based on the receiver's status),
it is displayed in the following format:
<Peer name> says: <message>
i.e: David says: hello world
The message can be displayed if the receiver is ONLINE.
peer
- The Person who sent the message.message
- The message that was sent.public java.lang.String toString()
public java.lang.String getName()
public java.lang.String toShortString()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |