class Boat
Attributes
set_of_grid_points[R]
Public Class Methods
new(set_of_grid_points)
click to toggle source
# File lib/boat.rb, line 5 def initialize(set_of_grid_points) @set_of_grid_points = Hash.new set_of_grid_points.each do |grid_point| @set_of_grid_points[grid_point] = false end end
Public Instance Methods
any_point_matched?(target_grid_point)
click to toggle source
# File lib/boat.rb, line 12 def any_point_matched?(target_grid_point) @set_of_grid_points.each_key do |grid_point| return true if grid_point == target_grid_point end false end
record_hit(target_grid_point)
click to toggle source
# File lib/boat.rb, line 19 def record_hit(target_grid_point) @set_of_grid_points[target_grid_point] = true end
sunk?()
click to toggle source
# File lib/boat.rb, line 23 def sunk? @set_of_grid_points.values.all? end