Skip to content
Snippets Groups Projects

feat: terrain is now selectable

Merged Carl Gützkow requested to merge feat/change-terrain into master
Files
5
@@ -11,7 +11,7 @@ import java.util.Random;
* Class Battle that simulates a battle between two armies.
*
* @author Carl Gützkow
* @version 1.2 13.02.2022
* @version 1.3 30.04.2022
*/
public class Battle {
@@ -34,13 +34,16 @@ public class Battle {
*
* @param armyOne Army - the first army
* @param armyTwo Army - the second army
* @throws IllegalArgumentException thrown if one of the armies are empty.
* @param terrain Terrain - on what terrain the battle is fought on.
* @throws IllegalArgumentException thrown if one of the armies are empty,
* if armies are equal or if terrain is not defined
* @throws NullPointerException thrown if one of the armies are null object
*/
public Battle(Army armyOne, Army armyTwo, Terrain terrain) throws IllegalArgumentException {
if (armyOne == null || armyTwo == null) throw new NullPointerException("Army is not defined");
if (!armyOne.hasUnits() || !armyTwo.hasUnits()) throw new IllegalArgumentException("Army can not be empty");
if (Objects.equals(armyOne, armyTwo)) throw new IllegalArgumentException("Armies can not be the same");
if (terrain == null) throw new IllegalArgumentException("Terrain is not defined");
this.armyOne = armyOne;
this.armyTwo = armyTwo;
this.terrain = terrain;
@@ -70,9 +73,9 @@ public class Battle {
/**
* Gets the terrain where
* the attack occurs.
* the battle occurs.
*
* @return terrain - Terrain - the specified terrain.
* @return terrain - Terrain - on what terrain the battle is fought on.
*/
public Terrain getTerrain() {
return terrain;
Loading