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.

66 lines
2.2 KiB

  1. package net.hoo2.auth.dsproject.snake;
  2. /**
  3. * @class Ladder
  4. * @brief Represent a Ladder in the Board.
  5. *
  6. * Ladders are part of the elements we place on the board.
  7. * They help the user to elevate rows. Each ladder can be used only once.
  8. *
  9. * @author Christos Choutouridis AEM:8997
  10. * @email cchoutou@ece.auth.gr
  11. */
  12. public class Ladder {
  13. /** @name Constructors */
  14. /** @{ */
  15. /** Default doing nothing constructor */
  16. Ladder () {
  17. ladderId = upStepId = downStepId =0;
  18. broken = false;
  19. }
  20. /**
  21. * @brief The main constructor
  22. * We create a ladder in the board
  23. * @param ladderId The id of ladder to create
  24. * @param upStepId The up-step tile of ladder
  25. * @param downStepId The down-step tile of ladder
  26. */
  27. Ladder (int ladderId, int upStepId, int downStepId) {
  28. this.ladderId = ladderId;
  29. this.upStepId = upStepId;
  30. this.downStepId = downStepId;
  31. this.broken = false; // A new ladder is always in good condition
  32. }
  33. /**
  34. * Copy constructor
  35. * @param l The ladder we want to copy
  36. */
  37. Ladder (Ladder l) {
  38. ladderId = l.getLadderId ();
  39. upStepId = l.getUpStepId ();
  40. downStepId = l.getDownStepId ();
  41. broken = l.getBroken ();
  42. }
  43. /** @} */
  44. /** @name Get/Set interface */
  45. /** @{ */
  46. int getLadderId () { return ladderId; }
  47. void setLadderId (int ladderId) { this.ladderId = ladderId; }
  48. int getUpStepId () { return upStepId; }
  49. void setUpStepId (int upStepId) { this.upStepId = upStepId; }
  50. int getDownStepId () { return downStepId; }
  51. void setDownStepId (int downStepId) { this.downStepId = downStepId; }
  52. boolean getBroken () { return broken; }
  53. void setBroken (boolean broken) { this.broken = broken; }
  54. /** @} */
  55. /** @name Data members */
  56. /** @{ */
  57. private int ladderId; /**< Ladder's ID */
  58. private int upStepId; /**< Ladder's upper step tile location */
  59. private int downStepId; /**< Snake's down step tile location */
  60. private boolean broken; /**< flag to indicate used/broken ladder */
  61. /** @} */
  62. }