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.

47 lines
1.3 KiB

  1. package SnakePkg;
  2. /**
  3. * A class to represent a Snake in the Board
  4. * @author Christos Choutouridis 8997
  5. */
  6. public class Snake {
  7. /** @name Constructors */
  8. /** @{ */
  9. /** Default ctor */
  10. Snake () {
  11. snakeId = headId = tailId = 0;
  12. }
  13. /** Main Constructor */
  14. Snake (int snakeId, int headId, int tailId) {
  15. this.snakeId = snakeId;
  16. this.headId = headId;
  17. this.tailId = tailId;
  18. }
  19. /** Copy constructor
  20. * @note We don't use clone as long as we don't inherit Cloneable iface
  21. */
  22. Snake (Snake s) {
  23. snakeId = s.getSnakeId ();
  24. headId = s.getHeadId ();
  25. tailId = s.getTailId ();
  26. }
  27. /** @} */
  28. /** @name Get/Set interface */
  29. /** @{ */
  30. int getSnakeId () { return snakeId; }
  31. void setSnakeId (int snakeId) { this.snakeId = snakeId; }
  32. int getHeadId () { return headId; }
  33. void setHeadId (int headId) { this.headId = headId; }
  34. int getTailId () { return tailId; }
  35. void setTailId (int tailId) { this.tailId = tailId; }
  36. /** @} */
  37. /** @name Data members (private) */
  38. /** @{ */
  39. private int snakeId; //!< Snake's ID
  40. private int headId; //!< Snake's head tile location
  41. private int tailId; //!< Snake's tail tile location
  42. /** @} */
  43. }