Hier das in der Übung implementierte Beispiel.
ClassModel model = new ClassModel("de.uniks.pm.battleship");
// Method checkWinnerMethod = new Method()
// .withSignature("checkWinner")
// .withReturnType("void");
//
Clazz battleship = model.createClazz("Battleship")
;//.withMethods(checkWinnerMethod);
Clazz field = model.createClazz("Field")
.withAttribute("x", "int")
.withAttribute("y", "int");
Clazz ship = model.createClazz("Ship")
.withAttribute("size", "int");
// Method fireMethod = new Method()
// .withSignature("fire(Field field)")
// .withReturnType("boolean");
Clazz player = model.createClazz("Player")
.withAttribute("turn", "boolean")
.withAttribute("name", "String")
;//.withMethods(fireMethod);
player.withAssoc(ship, "ship", R.MANY, "owner", R.ONE);
player.withAssoc(battleship, "battleshipGame", R.ONE, "player", R.MANY);
player.withAssoc(battleship, "wonGame", R.ONE, "winner", R.ONE);
player.withAssoc(field, "shotField", R.MANY, "player", R.MANY);
ship.withAssoc(field, "fields", R.MANY, "ships", R.MANY);
field.withAssoc(battleship, "battleshipGame", R.ONE, "field", R.MANY);
model.generate("genSrc");