A java snake game for A.U.TH. Data structures class
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7 KiB

  1. package net.hoo2.auth.dsproject.snake;
  2. /**
  3. * @class Snake
  4. * @brief Represent a Snake in the Board.
  5. *
  6. * Snakes are part of the elements we place on the board and they add
  7. * difficulty to the game.
  8. *
  9. * @author Christos Choutouridis AEM:8997
  10. * @email cchoutou@ece.auth.gr
  11. */
  12. public class Snake {
  13. /** @name Constructors */
  14. /** @{ */
  15. /** Default doing nothing constructor */
  16. Snake () {
  17. snakeId = headId = tailId = 0;
  18. }
  19. /**
  20. * @brief Main constructor
  21. * This creates a snake on the board.
  22. * @param snakeId The id of snake to create
  23. * @param headId The tile of snake's head
  24. * @param tailId The tile of snake's tail
  25. */
  26. Snake (int snakeId, int headId, int tailId) {
  27. this.snakeId = snakeId;
  28. this.headId = headId;
  29. this.tailId = tailId;
  30. }
  31. /** Copy constructor
  32. * @param s The snake we want to copy
  33. */
  34. Snake (Snake s) {
  35. snakeId = s.getSnakeId ();
  36. headId = s.getHeadId ();
  37. tailId = s.getTailId ();
  38. }
  39. /** @} */
  40. /** @name Get/Set interface */
  41. /** @{ */
  42. int getSnakeId () { return snakeId; }
  43. void setSnakeId (int snakeId) { this.snakeId = snakeId; }
  44. int getHeadId () { return headId; }
  45. void setHeadId (int headId) { this.headId = headId; }
  46. int getTailId () { return tailId; }
  47. void setTailId (int tailId) { this.tailId = tailId; }
  48. /** @} */
  49. /** @name Data members (private) */
  50. /** @{ */
  51. private int snakeId; /**< Snake's ID */
  52. private int headId; /**< Snake's head tile location */
  53. private int tailId; /**< Snake's tail tile location */
  54. /** @} */
  55. }