class BattleBoats::Ship

Attributes

length[R]
name[R]
symbol[R]

Public Class Methods

new(name:, length:, symbol: "O") click to toggle source
# File lib/battle_boats/ship.rb, line 5
def initialize(name:, length:, symbol: "O")
  @name = name
  @length = length
  @symbol = symbol
  @hits = 0
end

Public Instance Methods

empty?() click to toggle source
# File lib/battle_boats/ship.rb, line 12
def empty?
  false
end
hit() click to toggle source
# File lib/battle_boats/ship.rb, line 16
def hit
  @hits += 1
end
sunk?() click to toggle source
# File lib/battle_boats/ship.rb, line 20
def sunk?
  @hits == length
end