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
** need to add piece_moved?(boolean) to schema in "pieces" table. ** | |
class Pawn < Piece | |
def valid_move?(new_x, new_y) | |
return false if is_obstructed?(new_x.to_i, new_y.to_i) | |
return false if square_occupied?(new_x.to_i, new_y.to_i) | |
return true if pawn_capture?(new_x.to_i, new_y.to_i) | |
return true if move_two_squares_ok?(new_x.to_i, new_y.to_i) && !square_occupied?(new_x.to_i, new_y.to_i) | |
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 Dog | |
attr_accessor :name, :breed | |
def initialize(name, breed) | |
@name= name | |
@breed= breed | |
end | |
def to_s | |
"#{name} is a #{breed}." |
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 Image | |
def initialize (data) | |
@data = data | |
end | |
#write a method that loops through the existing 2D array and finds the | |
#location of the existing ones. The location of the the existing ones | |
#needs to be stored into memory so they can be iterated over and the | |
#exiting cells around them can be altered. |