public string VerifyGameBoardReady() { string boardReadyResponse = "Still need to set: "; if (!myDestroyer.GetLocationIsSet()) { boardReadyResponse += "Destroyer "; } if (!mySubmarine.GetLocationIsSet()) { boardReadyResponse += "Submarine "; } if (!myBattleship.GetLocationIsSet()) { boardReadyResponse += "Battleship "; } if (!myAircraftCarrier.GetLocationIsSet()) { boardReadyResponse += "Aircraft Carrier "; } if (myDestroyer.GetLocationIsSet() && mySubmarine.GetLocationIsSet() && myBattleship.GetLocationIsSet() && myAircraftCarrier.GetLocationIsSet()) { boardReadyResponse = "All are WET and READY!"; gameBoardReady = true; } return(boardReadyResponse); }
public bool NoOtherShipConflict(Destroyer destroyer, Submarine submarine, AircraftCarrier aircraftCarrier) { if (destroyer.GetLocationIsSet()) { for (int i = 0; i < destroyer.location.GetLength(0); i++) { if ((destroyer.location[i, 0] == location[0, 0] && destroyer.location[i, 1] == location[0, 0]) || (destroyer.location[i, 0] == location[1, 0] && destroyer.location[i, 1] == location[1, 1]) || (destroyer.location[i, 0] == location[2, 0] && destroyer.location[i, 1] == location[2, 1]) || (destroyer.location[i, 0] == location[3, 0] && destroyer.location[i, 1] == location[3, 1])) { return(false); } } } if (submarine.GetLocationIsSet()) { for (int i = 0; i < submarine.location.GetLength(0); i++) { if ((submarine.location[i, 0] == location[0, 0] && submarine.location[i, 1] == location[0, 0]) || (submarine.location[i, 0] == location[1, 0] && submarine.location[i, 1] == location[1, 1]) || (submarine.location[i, 0] == location[2, 0] && submarine.location[i, 1] == location[2, 1]) || (submarine.location[i, 0] == location[3, 0] && submarine.location[i, 1] == location[3, 1])) { return(false); } } } if (aircraftCarrier.GetLocationIsSet()) { for (int i = 0; i < aircraftCarrier.location.GetLength(0); i++) { if ((aircraftCarrier.location[i, 0] == location[0, 0] && aircraftCarrier.location[i, 1] == location[0, 0]) || (aircraftCarrier.location[i, 0] == location[1, 0] && aircraftCarrier.location[i, 1] == location[1, 1]) || (aircraftCarrier.location[i, 0] == location[2, 0] && aircraftCarrier.location[i, 1] == location[2, 1]) || (aircraftCarrier.location[i, 0] == location[3, 0] && aircraftCarrier.location[i, 1] == location[3, 1])) { return(false); } } } return(true); }
public bool NoOtherShipConflict(Destroyer destroyer, Battleship battleship, AircraftCarrier aircraftCarrier) { if (destroyer.GetLocationIsSet()) { for (int i = 0; i < destroyer.location.GetLength(0); i++) { if ((destroyer.location[i, 0] == location[0, 0] && destroyer.location[i, 1] == location[0, 0]) || (destroyer.location[i, 0] == location[1, 0] && destroyer.location[i, 1] == location[1, 1]) || (destroyer.location[i, 0] == location[2, 0] && destroyer.location[i, 1] == location[2, 1])) { return(false); } } } if (battleship.GetLocationIsSet()) { for (int i = 0; i < battleship.location.GetLength(0); i++) { if ((battleship.location[i, 0] == location[0, 0] && battleship.location[i, 1] == location[0, 0]) || (battleship.location[i, 0] == location[1, 0] && battleship.location[i, 1] == location[1, 1]) || (battleship.location[i, 0] == location[2, 0] && battleship.location[i, 1] == location[2, 1])) { return(false); } } } if (aircraftCarrier.GetLocationIsSet()) { for (int i = 0; i < aircraftCarrier.location.GetLength(0); i++) { if ((aircraftCarrier.location[i, 0] == location[0, 0] && aircraftCarrier.location[i, 1] == location[0, 0]) || (aircraftCarrier.location[i, 0] == location[1, 0] && aircraftCarrier.location[i, 1] == location[1, 1]) || (aircraftCarrier.location[i, 0] == location[2, 0] && aircraftCarrier.location[i, 1] == location[2, 1])) { return(false); } } } return(true); }
public bool NoOtherShipConflict(int x1, int y1, int x2, int y2, Submarine submarine, Battleship battleship, AircraftCarrier aircraftCarrier) { if (submarine.GetLocationIsSet()) { for (int i = 0; i < submarine.location.GetLength(0); i++) { if ((submarine.location[i, 0] == x1 && submarine.location[i, 1] == y1) || (submarine.location[i, 0] == x2 && submarine.location[i, 1] == y2)) { return(false); } } } if (battleship.GetLocationIsSet()) { for (int i = 0; i < battleship.location.GetLength(0); i++) { if ((battleship.location[i, 0] == x1 && battleship.location[i, 1] == y1) || (battleship.location[i, 0] == x2 && battleship.location[i, 1] == y2)) { return(false); } } } if (aircraftCarrier.GetLocationIsSet()) { for (int i = 0; i < aircraftCarrier.location.GetLength(0); i++) { if ((aircraftCarrier.location[i, 0] == x1 && aircraftCarrier.location[i, 1] == y1) || (aircraftCarrier.location[i, 0] == x2 && aircraftCarrier.location[i, 1] == y2)) { return(false); } } } return(true); }