|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.users.user.VoogaUser
public class VoogaUser
General class to represent functions required by a human VOOGA user. Provides ways to alter and get information about the internal data structures specific to the user such as favorite games, friends, logged in status, saved games etc. Two users cannot have the same name, an invariant maintained by the UserDatabase class.
VOOGAUser user1 = new VOOGAUser("user1");creates a new VOOGAUser with name "user1".
user1.getUserAvatar()returns the Avatar associated with user1. Now consider the following example:
VoogaUser user1 = new VoogaUser("user1"); VoogaUser user2 = new VoogaUser("user1");will never be called. The database will check to make sure that a given username is not taken before creating an User object. Constructors are protected because only the Database should be able to create new users (User doesn't know about the database so there is no checking to see if "name" is already the name of another User) For testing purposes, should you need to gain access to a VoogaUser, please use the following workaround:
UserDatabase db = new UserDatabase(); db.addUser("name", "password"); VoogaUser user = db.getUser("name");and then go on as planned with user.
Nested Class Summary | |
---|---|
static class |
VoogaUser.GameListFilter
|
Constructor Summary | |
---|---|
protected |
VoogaUser(java.rmi.server.UID uid,
java.lang.String name)
Constructor for a new user with name specified by name. |
protected |
VoogaUser(java.rmi.server.UID uid,
java.lang.String name,
java.lang.String password)
Constructor for a new user with name specified by name. |
protected |
VoogaUser(java.rmi.server.UID uid,
java.lang.String name,
java.lang.String password,
java.lang.String recoveryQuestion,
java.lang.String recoveryAnswer)
Constructor for a new user with the following properties. |
Method Summary | |
---|---|
void |
addFriend(VoogaUser friend)
adds friend to this user's list of friends |
void |
addGameStats(java.lang.String gameName)
adds the specified game to the myGameStats map |
void |
addToFavorites(java.lang.String gameName)
adds this game to the list of favorites |
protected void |
changeName(java.lang.String newname)
changes the name associated with this user. |
protected boolean |
changePassword(java.lang.String oldPassword,
java.lang.String newPassword)
Returns true if the conversion from oldPassword to newPassword is successful, false otherwise. |
boolean |
equals(java.lang.Object o)
|
java.lang.String |
getAboutMeText()
Returns this user's "about me text" |
java.util.List<java.lang.String> |
getAchievements(java.lang.String gameName)
gets the achievements for this user for the specified game |
java.util.Collection<java.lang.String> |
getFavoriteGames()
Gets this user's list of favorite games |
java.util.Set<java.lang.String> |
getFriendList()
Returns an unmodifiable set view of this user's friends |
java.util.Collection<AbstractVoogaReplay> |
getGameSaves(java.lang.String gameName)
Returns a Collection of all the AbstractGames associated with game for this user |
int |
getHighScore(java.lang.String gameName)
Returns this VoogaUser's high score for game. |
protected java.lang.String |
getRecoveryQuestion()
Returns this user's recovery question |
java.rmi.server.UID |
getUID()
Returns the UID (unique identifier) associated
with this user |
java.awt.image.BufferedImage |
getUserAvatar()
|
java.lang.String |
getUsername()
Returns a String that is this user's username |
boolean |
isLoggedIn()
|
protected boolean |
isPasswordValid(java.lang.String password)
Returns true if password is the correct password for this user |
boolean |
multipleGamesAllowed()
Returns true if multiple games are allowed for this VoogaUser. |
void |
recordHighScore(int score,
java.lang.String gameName)
Checks to see if score is a new high score for this user and if so, sets score as the high score. |
protected boolean |
recoverPassword(java.lang.String securityAnswer,
java.lang.String newPassword)
Returns true if the user's password was successfully changed |
void |
removeFriend(VoogaUser friend)
removes friend from this user's list of friends |
void |
removeFromFavorites(java.lang.String gameName)
remove this game from the list of favorites |
protected void |
setAboutMeText(java.lang.String aboutMeText)
Sets this user's "about me" text |
void |
setLoggedIn()
sets the logged in status of this user to be false. |
void |
setLoggedOut()
sets the logged in status of this user to be false |
void |
setMultipleGamesAllowed(boolean allowMultipleGames)
Sets the allowMultipleGames status for this VoogaUser |
protected void |
setRecoveryAnswer(java.lang.String answer)
Sets this user's recovery answer to this new value |
protected void |
setRecoveryQuestion(java.lang.String question)
Sets this user's recovery question to this new value |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected VoogaUser(java.rmi.server.UID uid, java.lang.String name)
name
- the name of the new userprotected VoogaUser(java.rmi.server.UID uid, java.lang.String name, java.lang.String password)
uid
- the UID to associate with this username
- the name of the new userpassword
- the password of the new userprotected VoogaUser(java.rmi.server.UID uid, java.lang.String name, java.lang.String password, java.lang.String recoveryQuestion, java.lang.String recoveryAnswer)
uid
- the UID to associate with this username
- the name of the new userpassword
- the password of the new userrecoveryQuestion
- the question the human will be asked to reset the
passwordrecoveryAnswer
- the answer that will allow the human to reset the
passwordMethod Detail |
---|
public java.lang.String getUsername()
public boolean multipleGamesAllowed()
public void setMultipleGamesAllowed(boolean allowMultipleGames)
allowMultipleGames
- true if multiple games are to be allowed for
this user, false otherwisepublic java.awt.image.BufferedImage getUserAvatar()
protected boolean isPasswordValid(java.lang.String password)
password
- the password to verify
public java.rmi.server.UID getUID()
UID
(unique identifier) associated
with this user
UID
(unique identifier) associated
with this userprotected boolean changePassword(java.lang.String oldPassword, java.lang.String newPassword)
oldPassword
- the current password for this usernewPassword
- the user's new password
public boolean isLoggedIn()
public java.util.Set<java.lang.String> getFriendList()
public void addGameStats(java.lang.String gameName)
game
- the game to add to the mappublic void addToFavorites(java.lang.String gameName)
gameName
- the game being added to the favorites listpublic void removeFromFavorites(java.lang.String gameName)
gameName
- the game being remove from the favorites listpublic void setLoggedOut()
public void setLoggedIn()
public java.util.Collection<AbstractVoogaReplay> getGameSaves(java.lang.String gameName)
game
- the game for which the caller wants the AbstractGames
public java.util.Collection<java.lang.String> getFavoriteGames()
protected void changeName(java.lang.String newname)
newname
- the new name of this userpublic java.util.List<java.lang.String> getAchievements(java.lang.String gameName)
game
- the game for which achievements are desired
public int getHighScore(java.lang.String gameName)
game
- the game being queried
public void recordHighScore(int score, java.lang.String gameName)
score
- the score to report for this usergame
- the game associated with the given scorepublic void addFriend(VoogaUser friend)
friend
- the user to add as a friendpublic void removeFriend(VoogaUser friend)
friend
- the user to remove as a friendpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String getRecoveryQuestion()
protected boolean recoverPassword(java.lang.String securityAnswer, java.lang.String newPassword)
securityAnswer
- the human's answernewPassword
- the human's new password
protected void setRecoveryQuestion(java.lang.String question)
question
- the new recovery questionprotected void setRecoveryAnswer(java.lang.String answer)
answer
- the new recovery answerprotected void setAboutMeText(java.lang.String aboutMeText)
aboutMeText
- the user's "about me" informationpublic java.lang.String getAboutMeText()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |