public void checkSpaceAvailable(Ship ship) { bool locationFound = false; bool cordInUse = true; Tuple <int, int>[] tupleArray; while (!locationFound && cordInUse) { int xcord = rancord.Next(0, 4); int ycord = rancord.Next(0, 4); int shipLength = ship.getTiles(); int maxCord = ycord + shipLength - 1; if (maxCord <= 4) { if (ship.getName() == "Frigate") { tupleArray = new Tuple <int, int>[3] { Tuple.Create(xcord, ycord), Tuple.Create(xcord, ycord + 1), Tuple.Create(xcord, ycord + 2), }; cordInUse = isNewCordsValidlocation(tupleArray); if (!cordInUse) { for (int j = 0; j < tupleArray.Length; j++) { Tuple <int, int> currentTuple = tupleArray[j]; Ship.tilesInUse[currentTuple.Item1, currentTuple.Item2] = 1; map[currentTuple.Item1, currentTuple.Item2] = "F"; } } } else if (ship.getName() == "Attack_Boat") { tupleArray = new Tuple <int, int>[2] { Tuple.Create(xcord, ycord), Tuple.Create(xcord, ycord + 1), }; cordInUse = isNewCordsValidlocation(tupleArray); if (!cordInUse) { for (int j = 0; j < tupleArray.Length; j++) { Tuple <int, int> currentTuple = tupleArray[j]; Ship.tilesInUse[currentTuple.Item1, currentTuple.Item2] = 1; map[currentTuple.Item1, currentTuple.Item2] = "A"; } } } else if (ship.getName() == "Dingy") { tupleArray = new Tuple <int, int>[1] { Tuple.Create(xcord, ycord), }; cordInUse = isNewCordsValidlocation(tupleArray); if (!cordInUse) { for (int j = 0; j < tupleArray.Length; j++) { Tuple <int, int> currentTuple = tupleArray[j]; Ship.tilesInUse[currentTuple.Item1, currentTuple.Item2] = 1; map[currentTuple.Item1, currentTuple.Item2] = "D"; } } } else { // } } else { } } }