Developing TicToe HTML5/Implementing Server Entities: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Hendrik Brummermann |
imported>Hendrik Brummermann |
||
| Line 180: | Line 180: | ||
== Player class == |
== Player class == |
||
The last entity class is the one which represents players. For now, they just have a name, but later they will represent the clients and may be extended to full avatars with nice outfits. |
|||
{{TODO|Write this section}} |
|||
<source lang="java"> |
|||
... |
|||
public class Player extends Entity { |
|||
private static final String ATTR_PLAYER_NAME = "playerName"; |
|||
... |
|||
/** |
|||
* gets the name of the player |
|||
* |
|||
* @return name of player |
|||
*/ |
|||
public String getPlayerName() { |
|||
return super.get(ATTR_PLAYER_NAME); |
|||
} |
|||
/** |
|||
* sets the name of the player |
|||
* |
|||
* @param playerName |
|||
*/ |
|||
public void setPlayerName(String playerName) { |
|||
super.put(ATTR_PLAYER_NAME, playerName); |
|||
} |
|||
/** |
|||
* generates the RPClass |
|||
*/ |
|||
public static void generateRPClass() { |
|||
RPClass clazz = new RPClass("player"); |
|||
clazz.addAttribute(ATTR_PLAYER_NAME, Type.STRING); |
|||
clazz.isA("entity"); |
|||
} |
|||
} |
|||
</source> |
|||
Again the imports and constructors have been left out. |
|||