C# Class BattleShip.FileManager

Show file Open project: LucienCamuglia/Battleships Class Usage Examples

Public Methods

Method Description
FileManager ( string path, string pseudo ) : System

Constructor for creating new game

FileManager ( string path, string pseudo, string filename ) : System

Constructor for joining a game

ReadCurrentPlayer ( ) : string
ReadPlayers ( ) : string[]

Read the both players

SwitchCurrentPlayer ( ) : void
WriteBattleBoard ( int x, int y, int value ) : void

readBoard ( string boardType, string player ) : ].int[
writeBoard ( string boardType, string player, int x, int y, int value ) : void

Private Methods

Method Description
ChangeFileStatus ( bool _lock ) : void

lock or unlock the bnav file The lock work with a copy of the original file with '.lock' at the end. - ex 'BN-V02-2016-01-02-14-20-50.bnav.lock' To unlock the original file the '.lock' file is deleted

CreateFiles ( string myPath ) : void

Create the BNAV file for the game

JoinGame ( string path, string filename, string pseudo ) : bool

Join a curent game

fileIsLocked ( ) : bool

Check if the file is locked

writePseudo ( string player, string pseudo ) : void

Write the pseudo of the player in the file

Method Details

FileManager() public method

Constructor for creating new game
public FileManager ( string path, string pseudo ) : System
path string
pseudo string
return System

FileManager() public method

Constructor for joining a game
public FileManager ( string path, string pseudo, string filename ) : System
path string
pseudo string
filename string
return System

ReadCurrentPlayer() public method

public ReadCurrentPlayer ( ) : string
return string

ReadPlayers() public method

Read the both players
public ReadPlayers ( ) : string[]
return string[]

SwitchCurrentPlayer() public method

public SwitchCurrentPlayer ( ) : void
return void

WriteBattleBoard() public method

public WriteBattleBoard ( int x, int y, int value ) : void
x int
y int
value int
return void

readBoard() public method

public readBoard ( string boardType, string player ) : ].int[
boardType string
player string
return ].int[

writeBoard() public method

public writeBoard ( string boardType, string player, int x, int y, int value ) : void
boardType string
player string
x int
y int
value int
return void