Package battleship.model
Class Game
java.lang.Object
battleship.model.Game
public class Game
extends java.lang.Object
Main game class
-
Field Summary
Fields Modifier and Type Field Description PlayercurrentPlayerPlayer[]players -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidchangeCurrentPlayer()voidcheckDrownedShips()Update ship to know if they're drownedPlayergetCurrentPlayer()PlayergetOtherPlayer()PlayergetOtherPlayer(Player player)PlayergetWinner()voidmove(Pair<java.lang.Integer,java.lang.Integer> move)Play the selected move from current player in gridvoidPlay(View view)game loopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
players
-
currentPlayer
-
-
Constructor Details
-
Game
-
-
Method Details
-
getCurrentPlayer
-
getOtherPlayer
-
getOtherPlayer
-
changeCurrentPlayer
public void changeCurrentPlayer() -
checkDrownedShips
public void checkDrownedShips()Update ship to know if they're drowned -
getWinner
- Returns:
- player 1 if player 2' ships are drowned, or player 2 if player1' ships are drowned, null otherwise
-
move
Play the selected move from current player in grid- Parameters:
move- selected player move
-
Play
game loop
-