blather.model
Class BlatherUser

java.lang.Object
  extended by blather.model.BlatherUser
All Implemented Interfaces:
BlatherUserInterface, java.io.Serializable

public class BlatherUser
extends java.lang.Object
implements java.io.Serializable, BlatherUserInterface

BlatherUser models a user of the Blather application. A user has a username, an email address, a password, and a collection of friends (other BlatherUsers).

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface blather.model.BlatherUserInterface
serialVersionUID
 
Constructor Summary
BlatherUser(java.lang.String username, java.lang.String password, EmailAddressInterface email)
          Creates a new BlatherUser with the given username, password, and address.
 
Method Summary
 void addBlab(BlabInterface b)
          Creates a new blab for this user.
 void addFriend(BlatherUserInterface newFriend)
          Adds a new friend, so that this BlatherUser will be tracking the blabs of newFriend.
 int blabCount()
          Returns the number of blabs this user has posted.
 boolean checkPassword(java.lang.String password)
          Returns true if the given password is correct for this BlatherUser, false otherwise.
 int friendCount()
          Returns the number of BlatherUsers this user has befriended.
 BlabInterface[] getAllBlabs()
          Returns a copy of the array of all Blabs authored by this user.
 BlabInterface getBlab(int id)
          Returns this user's blab with the given identifier.
 EmailAddressInterface getEmail()
          Returns this BlatherUser's email address
 BlatherUserInterface getFriend(int id)
          Returns a BlatherUser corresponding to this user's friend with friend identifier id.
 java.lang.String getUsername()
          Returns this BlatherUser's username (that is, his or her display name).
 void setEmail(EmailAddressInterface email)
          Updates this BlatherUser's email address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlatherUser

public BlatherUser(java.lang.String username,
                   java.lang.String password,
                   EmailAddressInterface email)
Creates a new BlatherUser with the given username, password, and address.

Parameters:
username -
password -
address -
Method Detail

getUsername

public java.lang.String getUsername()
Description copied from interface: BlatherUserInterface
Returns this BlatherUser's username (that is, his or her display name).

Specified by:
getUsername in interface BlatherUserInterface
Returns:
this BlatherUser's username

getEmail

public EmailAddressInterface getEmail()
Description copied from interface: BlatherUserInterface
Returns this BlatherUser's email address

Specified by:
getEmail in interface BlatherUserInterface
Returns:

setEmail

public void setEmail(EmailAddressInterface email)
Description copied from interface: BlatherUserInterface
Updates this BlatherUser's email address.

Specified by:
setEmail in interface BlatherUserInterface

checkPassword

public boolean checkPassword(java.lang.String password)
Description copied from interface: BlatherUserInterface
Returns true if the given password is correct for this BlatherUser, false otherwise.

Specified by:
checkPassword in interface BlatherUserInterface
Returns:

friendCount

public int friendCount()
Description copied from interface: BlatherUserInterface
Returns the number of BlatherUsers this user has befriended.

Specified by:
friendCount in interface BlatherUserInterface
Returns:

getFriend

public BlatherUserInterface getFriend(int id)
Description copied from interface: BlatherUserInterface
Returns a BlatherUser corresponding to this user's friend with friend identifier id. Precondition: id is greater than or equal to 0 and strictly less than this.friendCount()

Specified by:
getFriend in interface BlatherUserInterface
Parameters:
id - the id number of the friend to return

addFriend

public void addFriend(BlatherUserInterface newFriend)
Description copied from interface: BlatherUserInterface
Adds a new friend, so that this BlatherUser will be tracking the blabs of newFriend.

Specified by:
addFriend in interface BlatherUserInterface

blabCount

public int blabCount()
Description copied from interface: BlatherUserInterface
Returns the number of blabs this user has posted.

Specified by:
blabCount in interface BlatherUserInterface
Returns:

getBlab

public BlabInterface getBlab(int id)
Description copied from interface: BlatherUserInterface
Returns this user's blab with the given identifier.

Specified by:
getBlab in interface BlatherUserInterface
Returns:

addBlab

public void addBlab(BlabInterface b)
Description copied from interface: BlatherUserInterface
Creates a new blab for this user.

Specified by:
addBlab in interface BlatherUserInterface

getAllBlabs

public BlabInterface[] getAllBlabs()
Description copied from interface: BlatherUserInterface
Returns a copy of the array of all Blabs authored by this user.

Specified by:
getAllBlabs in interface BlatherUserInterface
Returns:
Returns a copy of the array of all Blabs authored by this user.