Skip to content

Instantly share code, notes, and snippets.

@mariovisic
Last active April 18, 2018 03:24
Show Gist options
  • Save mariovisic/80e39f3e5be4df66ce7d0cbb5b95721a to your computer and use it in GitHub Desktop.
Save mariovisic/80e39f3e5be4df66ce7d0cbb5b95721a to your computer and use it in GitHub Desktop.
Battleship game from the study group
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)
@ppj
Copy link

ppj commented Apr 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment