Commit 10684db8 authored by Mamadou Saliou DIALLO's avatar Mamadou Saliou DIALLO
Browse files

feat: handle BoardGame association on Square

parent 217721f0
package fr.univnantes.alma.model; package fr.univnantes.alma.model;
import fr.univnantes.alma.model.square.Square;
import fr.univnantes.alma.references.associations.BidirectionalOneToMany;
import fr.univnantes.alma.references.interfaces.OneToManyAssociation;
/** /**
* Board game. * Board game.
*/ */
public class BoardGame { public class BoardGame {
/**
* Board game squares.
*/
OneToManyAssociation<BoardGame, Square> squares;
public BoardGame() {
squares = new BidirectionalOneToMany<>(this, Square::getBoardGame);
}
/**
* Return all squares on the board game.
* @return
*/
public OneToManyAssociation<BoardGame, Square> getSquares() {
return squares;
}
} }
package fr.univnantes.alma.model.square; package fr.univnantes.alma.model.square;
import fr.univnantes.alma.model.BoardGame;
import fr.univnantes.alma.model.Pawn; import fr.univnantes.alma.model.Pawn;
import fr.univnantes.alma.references.associations.BidirectionalManyToOne;
import fr.univnantes.alma.references.associations.BidirectionalOneToOne; import fr.univnantes.alma.references.associations.BidirectionalOneToOne;
import fr.univnantes.alma.references.interfaces.ManyToOneAssociation;
import fr.univnantes.alma.references.interfaces.OneToOneAssociation; import fr.univnantes.alma.references.interfaces.OneToOneAssociation;
/*** /***
...@@ -19,6 +22,11 @@ public abstract class Square { ...@@ -19,6 +22,11 @@ public abstract class Square {
*/ */
private OneToOneAssociation<Square, Pawn> pawn; private OneToOneAssociation<Square, Pawn> pawn;
/**
* Board game where the square is located.
*/
private ManyToOneAssociation<Square, BoardGame> boardGame;
/** /**
* Create new instance of Square. * Create new instance of Square.
* @param squarePosition square position * @param squarePosition square position
...@@ -26,6 +34,7 @@ public abstract class Square { ...@@ -26,6 +34,7 @@ public abstract class Square {
public Square(final int squarePosition) { public Square(final int squarePosition) {
this.position = squarePosition; this.position = squarePosition;
pawn = new BidirectionalOneToOne<>(this, Pawn::getSquare); pawn = new BidirectionalOneToOne<>(this, Pawn::getSquare);
boardGame = new BidirectionalManyToOne<>(this, BoardGame::getSquares);
} }
/** /**
...@@ -43,4 +52,12 @@ public abstract class Square { ...@@ -43,4 +52,12 @@ public abstract class Square {
public OneToOneAssociation<Square, Pawn> getPawn() { public OneToOneAssociation<Square, Pawn> getPawn() {
return pawn; return pawn;
} }
/**
* Return the board game were the square is located.
* @return BoardGame
*/
public ManyToOneAssociation<Square, BoardGame> getBoardGame() {
return boardGame;
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment