mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-07-05 23:54:43 +02:00
Flytter ting til korrekte pakker og forbedrer Tile og Wall
Fikser kommentarer, mellomrom og variabelnavn i Tile og Wall Flytter IGrid, Robot og Wall til objects Flytter tester til korresponderende pakker
This commit is contained in:
src
main
java
inf112
fiasko
roborally
test
java
inf112
fiasko
roborally
37
src/main/java/inf112/fiasko/roborally/objects/IGrid.java
Normal file
37
src/main/java/inf112/fiasko/roborally/objects/IGrid.java
Normal file
@ -0,0 +1,37 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
/**
|
||||
* This Interface describes a grid
|
||||
* @param <K> type of element
|
||||
*/
|
||||
public interface IGrid<K> {
|
||||
|
||||
/**
|
||||
* returns the width of the grid
|
||||
* @return the width
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* returns the height of the grid
|
||||
* @return the height
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* returns the element in a given x and y coordinate
|
||||
* @param x coordinate in the grid
|
||||
* @param y coordinate in the grid
|
||||
* @return element in the x and y coordinate
|
||||
* @throws IllegalArgumentException throws exception if coordinates are not in the grid
|
||||
*/
|
||||
K getElement(int x,int y) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* places the element in the given x and y coordinate
|
||||
* @param x coordinate
|
||||
* @param y coordinate
|
||||
* @param element that is being placed in the grid
|
||||
*/
|
||||
void setElement(int x, int y, K element);
|
||||
}
|
43
src/main/java/inf112/fiasko/roborally/objects/Robot.java
Normal file
43
src/main/java/inf112/fiasko/roborally/objects/Robot.java
Normal file
@ -0,0 +1,43 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Position;
|
||||
|
||||
/**
|
||||
* this class represents a robot
|
||||
*/
|
||||
public class Robot {
|
||||
private int robotDamageTaken = 0;
|
||||
private int playerId; //might not be needed
|
||||
private boolean inPowerDown = false;
|
||||
private int lastFlagVisited = 0;
|
||||
private Position backupPosition;
|
||||
private Position currentPosition;
|
||||
|
||||
|
||||
public Robot (int playerId, Position spawnPosition){
|
||||
this.playerId=playerId;
|
||||
this.backupPosition = spawnPosition;
|
||||
this.currentPosition = spawnPosition;
|
||||
}
|
||||
|
||||
|
||||
public int getDamage(){
|
||||
return robotDamageTaken;
|
||||
}
|
||||
public void setDamage (int damage){
|
||||
this.robotDamageTaken = damage;
|
||||
}
|
||||
public Position getPosition(){
|
||||
return currentPosition;
|
||||
}
|
||||
public void setPosition( Position newPosition ){
|
||||
this.currentPosition = newPosition;
|
||||
}
|
||||
public void setPowerDown(Boolean powerDownStatus){
|
||||
this.inPowerDown = powerDownStatus;
|
||||
}
|
||||
public Boolean isInPowerDown(){
|
||||
return inPowerDown;
|
||||
}
|
||||
|
||||
}
|
@ -3,38 +3,38 @@ package inf112.fiasko.roborally.objects;
|
||||
import inf112.fiasko.roborally.element_properties.Direction;
|
||||
import inf112.fiasko.roborally.element_properties.TileType;
|
||||
|
||||
/**
|
||||
* This class represents a simple tile
|
||||
*/
|
||||
public class Tile {
|
||||
|
||||
/**
|
||||
* tileType stores the type of the specific tile.
|
||||
*/
|
||||
private TileType tileType;
|
||||
/**
|
||||
* direction stores the direction of the specific tile.
|
||||
*/
|
||||
private Direction direction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tileType sets the type of the tile.
|
||||
* @param direction sets the direction the tile is facing.
|
||||
* Instantiates a new tile
|
||||
* @param tileType The type of the tile
|
||||
* @param direction The direction of the tile
|
||||
*/
|
||||
public Tile(TileType tileType, Direction direction) {
|
||||
if (direction.getDirectionID() % 2 == 0) {
|
||||
throw new IllegalArgumentException("Invalid direction for tile submitted");
|
||||
}
|
||||
this.tileType = tileType;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the type of the specific tile.
|
||||
* Gets the tile type of the tile
|
||||
* @return The tile's tile type
|
||||
*/
|
||||
public TileType getTileType() {
|
||||
return tileType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the direction of the specific tile.
|
||||
* Gets the direction of the tile
|
||||
* @return The tile's direction
|
||||
*/
|
||||
public Direction getDirection() {
|
||||
return direction;
|
||||
|
39
src/main/java/inf112/fiasko/roborally/objects/Wall.java
Normal file
39
src/main/java/inf112/fiasko/roborally/objects/Wall.java
Normal file
@ -0,0 +1,39 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Direction;
|
||||
import inf112.fiasko.roborally.element_properties.WallType;
|
||||
|
||||
/**
|
||||
* This class represents a wall
|
||||
*/
|
||||
public class Wall {
|
||||
|
||||
private WallType wallType;
|
||||
private Direction direction;
|
||||
|
||||
/**
|
||||
* Initializes a wall
|
||||
* @param wallType The type of the wall
|
||||
* @param direction The direction of the wall
|
||||
*/
|
||||
public Wall (WallType wallType, Direction direction) {
|
||||
this.wallType = wallType;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the wall
|
||||
* @return The wall type
|
||||
*/
|
||||
public WallType getWallType() {
|
||||
return wallType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the direction of the wall
|
||||
* @return The direction of the wall
|
||||
*/
|
||||
public Direction getDirection(){
|
||||
return direction;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user