Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package g54368.humbug.model;
- import g54368.humbug.model.*;
- /**
- *
- * @author Akwatic
- */
- public abstract class Animal {
- private Position positionOnBoard;
- private boolean onStar;
- public Animal(Position position) {
- this.positionOnBoard = position;
- this.onStar = false;
- }
- public abstract Position move(Board board, Direction direction, Animal ... animals);
- /**
- * Simple setter of the position on the board for the animals
- *
- * @return position
- */
- public void setPositionOnBoard(Position position){
- this.positionOnBoard = position;
- }
- /**
- * Simple getter of position on the board
- *
- * @return position on the board
- */
- public Position getPositionOnBoard() {
- return positionOnBoard;
- }
- /**
- * Boolean is on star
- *
- * @return onStar
- */
- public boolean isOnStar(){
- System.out.print(getPositionOnBoard());
- System.out.print(" is on star2 ");
- return onStar;
- }
- /**
- * Simple setter of onstar.
- *
- * @return onStar true
- */
- public void setOnStar(){
- System.out.print(getPositionOnBoard());
- System.out.print(" set on star2 ");
- this.onStar = true;
- }
- protected boolean isAnimalOnPos(Position targetPosition, Animal... animals) {
- for (Animal animal: animals) {
- if (animal.getPositionOnBoard().equals(targetPosition)) {
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement