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 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 |
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 Automobile | |
attr_accessor :year, :make, :model | |
def initialize(year, make, model) | |
self.year = year | |
self.make = make | |
self.model = model | |
end |