Last active
April 18, 2018 03:24
-
-
Save mariovisic/80e39f3e5be4df66ce7d0cbb5b95721a to your computer and use it in GitHub Desktop.
Battleship game from the study group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Game | |
attr_reader :player_one, :player_two, :board_one | |
def initialize(name_one, name_two) | |
@player_one = Player.new(name_one) | |
@player_two = Player.new(name_two) | |
@board_one = Board.new | |
end | |
end | |
class Player | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
end | |
class Board | |
end | |
RSpec.describe Game do | |
let(:game) { Game.new('Janice', 'Bob') } | |
it 'has two players ' do | |
expect(game.player_one.name).to eq('Janice') | |
expect(game.player_two.name).to eq('Bob') | |
end | |
it 'has two boards' do | |
expect(game.board_one).to be | |
board_one = Board.new | |
board_two = Board.new | |
end | |
it 'allows us to set the players names' do | |
player_one = Player.new('Janice') | |
player_two = Player.new('Bob') | |
expect(player_one.name).to eq('Janice') | |
expect(player_two.name).to eq('Bob') | |
end | |
end | |
# nouns (objects, class) | |
# verbs (actions, methods) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on https://www.cs.nmsu.edu/~bdu/TA/487/brules.htm