A java snake game for A.U.TH. Data structures class
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

53 lignes
1.7 KiB

  1. package SnakePkg;
  2. /**
  3. * A class to represent a Ladder in the Board
  4. * @author Christos Choutouridis 8997
  5. */
  6. public class Ladder {
  7. /** @name Constructors */
  8. /** @{ */
  9. /** Default ctor */
  10. Ladder () {
  11. ladderId = upStepId = downStepId =0;
  12. broken = false;
  13. }
  14. /** Main ctor */
  15. Ladder (int ladderId, int upStepId, int downStepId) {
  16. this.ladderId = ladderId;
  17. this.upStepId = upStepId;
  18. this.downStepId = downStepId;
  19. this.broken = false; // A new ladder is always in good condition
  20. }
  21. /** Copy constructor
  22. * @note We don't use clone as long as we don't inherit Cloneable iface
  23. */
  24. Ladder (Ladder l) {
  25. ladderId = l.getLadderId ();
  26. upStepId = l.getUpStepId ();
  27. downStepId = l.getDownStepId ();
  28. broken = l.getBroken ();
  29. }
  30. /** @} */
  31. /** @name Get/Set interface */
  32. /** @{ */
  33. int getLadderId () { return ladderId; }
  34. void setLadderId (int ladderId) { this.ladderId = ladderId; }
  35. int getUpStepId () { return upStepId; }
  36. void setUpStepId (int upStepId) { this.upStepId = upStepId; }
  37. int getDownStepId () { return downStepId; }
  38. void setDownStepId (int downStepId) { this.downStepId = downStepId; }
  39. boolean getBroken () { return broken; }
  40. void setBroken (boolean broken) { this.broken = broken; }
  41. /** @} */
  42. /** @name Data members (private) */
  43. /** @{ */
  44. private int ladderId; //!< Ladder's ID
  45. private int upStepId; //!< Ladder's upper step tile location
  46. private int downStepId; //!< Snake's down step tile location
  47. private boolean broken; //!< flag to indicate used/broken ladder
  48. /** @} */
  49. }