Skip to content

Instantly share code, notes, and snippets.

View mattheweves's full-sized avatar

Matt Eves mattheweves

  • California Nomad
View GitHub Profile
class Knight < Piece
def valid_move?(x, y)
# Knight has no concern for obstruction, only check required is valid move of spaces.
return true if (self.x_position - x).abs == 2 && (self.y_position - y).abs == 1
return true if (self.x_position - x).abs == 1 && (self.y_position - y).abs == 2
return false
end
end
@mattheweves
mattheweves / auto.rb
Created August 22, 2015 15:17
Firehose Quiz 3: OOP - A Class
class Automobile
attr_accessor :year, :make, :model
def initialize(year, make, model)
self.year = year
self.make = make
self.model = model
end