diff --git a/battleship/src/components/gameboard.js b/battleship/src/components/gameboard.js index 750aa89..5b614e7 100644 --- a/battleship/src/components/gameboard.js +++ b/battleship/src/components/gameboard.js @@ -1,5 +1,4 @@ import { Ship } from './ship'; -let _ = require('lodash'); class Gameboard { constructor() { diff --git a/battleship/src/components/player.js b/battleship/src/components/player.js new file mode 100644 index 0000000..3970185 --- /dev/null +++ b/battleship/src/components/player.js @@ -0,0 +1,9 @@ +import { Gameboard } from './gameboard'; +class Player { + constructor(name) { + this.gameboard = new Gameboard(); + this.playerName = name; + } +} + +export { Player }; diff --git a/battleship/src/index.js b/battleship/src/index.js index e69de29..938f857 100644 --- a/battleship/src/index.js +++ b/battleship/src/index.js @@ -0,0 +1,7 @@ +import { Player } from './components/player'; + +const player1 = new Player('Player 1'); +const player2 = new Player('CPU'); + +console.log(player1.gameboard); +console.log(player2.gameboard); diff --git a/battleship/tests/player.test.js b/battleship/tests/player.test.js new file mode 100644 index 0000000..65cefa8 --- /dev/null +++ b/battleship/tests/player.test.js @@ -0,0 +1,18 @@ +import { Gameboard } from '../src/components/gameboard'; +class Player { + constructor(name) { + this.gameboard = new Gameboard(); + this.playerName = name; + } +} + +let p = new Player('Player1'); + +it('should contain a gameboard', () => { + expect(p.gameboard).toHaveProperty( + 'ships', + 'scoreboard', + 'shipCount', + 'sunkShipCount', + ); +});