Advertisement
akwatic97460

Untitled

Mar 29th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. package g54368.humbug.model;
  2. import g54368.humbug.model.*;
  3. /**
  4. *
  5. * @author Akwatic
  6. */
  7. public abstract class Animal {
  8. private Position positionOnBoard;
  9. private boolean onStar;
  10.  
  11. public Animal(Position position) {
  12. this.positionOnBoard = position;
  13. this.onStar = false;
  14. }
  15.  
  16. public abstract Position move(Board board, Direction direction, Animal ... animals);
  17.  
  18. /**
  19. * Simple setter of the position on the board for the animals
  20. *
  21. * @return position
  22. */
  23.  
  24. public void setPositionOnBoard(Position position){
  25. this.positionOnBoard = position;
  26. }
  27.  
  28. /**
  29. * Simple getter of position on the board
  30. *
  31. * @return position on the board
  32. */
  33.  
  34. public Position getPositionOnBoard() {
  35. return positionOnBoard;
  36. }
  37.  
  38. /**
  39. * Boolean is on star
  40. *
  41. * @return onStar
  42. */
  43.  
  44. public boolean isOnStar(){
  45. System.out.print(getPositionOnBoard());
  46. System.out.print(" is on star2 ");
  47. return onStar;
  48. }
  49.  
  50. /**
  51. * Simple setter of onstar.
  52. *
  53. * @return onStar true
  54. */
  55.  
  56. public void setOnStar(){
  57. System.out.print(getPositionOnBoard());
  58. System.out.print(" set on star2 ");
  59. this.onStar = true;
  60. }
  61.  
  62. protected boolean isAnimalOnPos(Position targetPosition, Animal... animals) {
  63. for (Animal animal: animals) {
  64. if (animal.getPositionOnBoard().equals(targetPosition)) {
  65. return true;
  66. }
  67. }
  68.  
  69. return false;
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement