Developing TicToe HTML5/Implementing Server Entities: Difference between revisions

Content deleted Content added
imported>Hendrik Brummermann
imported>Hendrik Brummermann
Line 139:
== Token class ==
 
The token class extends Entity like the Gameboard did. But it adds a tokenType attribute:
{{TODO|Write this section}}
 
<source lang="java">
...
public class Token extends Entity {
private static final String ATTR_TOKEN_TYPE = "tokenType";
 
...
 
/**
* gets the token type.
*
* @return "x" or "o"
*/
public String getTokenType() {
return super.get(ATTR_TOKEN_TYPE);
}
 
/**
* sets the token type.
*
* @param tokenType type of token ("x", "o")
*/
public void setTokenType(String tokenType) {
super.put(ATTR_TOKEN_TYPE, tokenType);
}
 
/**
* generates the RPClass
*/
public static void generateRPClass() {
RPClass clazz = new RPClass("token");
clazz.addAttribute(ATTR_TOKEN_TYPE, Type.STRING);
clazz.isA("entity");
}
</source>
 
Note: We have left out the imports and constructors as they follow the pattern of the previous shown classes.
 
== Player class ==