60 lines
1.7 KiB
Java
Executable File
60 lines
1.7 KiB
Java
Executable File
package SnakePkg;
|
|
|
|
/**
|
|
* @class Snake
|
|
* @brief Represent a Snake in the Board.
|
|
*
|
|
* Snakes are part of the elements we place on the board and they add
|
|
* difficulty to the game.
|
|
*
|
|
* @author Christos Choutouridis 8997
|
|
* @email cchoutou@ece.auth.gr
|
|
*/
|
|
public class Snake {
|
|
/** @name Constructors */
|
|
/** @{ */
|
|
/** Default doing nothing constructor */
|
|
Snake () {
|
|
snakeId = headId = tailId = 0;
|
|
}
|
|
|
|
/**
|
|
* @brief Main constructor
|
|
* This creates a snake on the board.
|
|
* @param snakeId The id of snake to create
|
|
* @param headId The tile of snake's head
|
|
* @param tailId The tile of snake's tail
|
|
*/
|
|
Snake (int snakeId, int headId, int tailId) {
|
|
this.snakeId = snakeId;
|
|
this.headId = headId;
|
|
this.tailId = tailId;
|
|
}
|
|
/** Copy constructor
|
|
* @param s The snake we want to copy
|
|
*/
|
|
Snake (Snake s) {
|
|
snakeId = s.getSnakeId ();
|
|
headId = s.getHeadId ();
|
|
tailId = s.getTailId ();
|
|
}
|
|
/** @} */
|
|
|
|
/** @name Get/Set interface */
|
|
/** @{ */
|
|
int getSnakeId () { return snakeId; }
|
|
void setSnakeId (int snakeId) { this.snakeId = snakeId; }
|
|
int getHeadId () { return headId; }
|
|
void setHeadId (int headId) { this.headId = headId; }
|
|
int getTailId () { return tailId; }
|
|
void setTailId (int tailId) { this.tailId = tailId; }
|
|
/** @} */
|
|
|
|
/** @name Data members (private) */
|
|
/** @{ */
|
|
private int snakeId; /**< Snake's ID */
|
|
private int headId; /**< Snake's head tile location */
|
|
private int tailId; /**< Snake's tail tile location */
|
|
/** @} */
|
|
}
|