/* isp * * Input variables: * SelectedShip = valid ship names, invalid ship names * amountOfShips = 0, >0 * rowposition = <0, >0 && <6, >=6 * * State variables: * row = empty || null, not empty * rowPosition = null, ship formation exists * */ public void UpdateFormationRow(Ship selectedShip, uint amountOfShips, uint rowPosition) { if (rowPosition < 6 && rowPosition >= 0) { Rows[rowPosition] = new FormationRow(selectedShip, amountOfShips); } else { throw new Exception("Invalid Row Position"); } }
/* isp * * Input variables: * SelectedShip = valid ship names, invalid ship names * amountOfShips = 0, >0 * rowposition = <0, >0 && <6, >=6 * * State variables: * row = empty || null, not empty * rowPosition = null, ship formation exists * */ public void SetFormationRow(Ship selectedShip, uint amountOfShips, uint rowPosition) { if (Rows[rowPosition] != null) { throw new Exception("Slot not empty"); } else if (rowPosition < 6 && rowPosition >= 0) { Rows[rowPosition] = new FormationRow(selectedShip, amountOfShips); } else { throw new Exception("Invalid Row Position"); } }
public BattleFormation(string name) { Name = name; Rows = new FormationRow[6]; }