- Create, access, and traverse nested data structures
- Implement a basic Ruby class and identify when to use instance variables
Create a class BoggleBoard
that includes the functionality of your methods from the Boggle Board challenge you completed last week.
To do this, take a look at the methods you've created. How can they be integrated into your BoggleBoard class? What needs to change?
Transform your Driver Test Code so that it creates a new board object. You'll need to pass the original 2D array as an argument. (Let's call that dice_grid
because boggle_board is going to be its own object now!) This is already in your solution file. How does the boggle_board
object hold the dice_grid
?
One method at a time, create a test to access your new boggle_board
object. The first method should be #create_word
. (Don't get thrown off with the #method_name
syntax, using #
before a method name is a ruby convention.) Write out a test with it's expectation in a comment, and then create the method in the BoggleBoard
class. Try these coordinates: (1,2), (1,1), (2,1), (3,2).
Then, write methods for #get_row
and #get_col
. Can you interact with the boggle_board object and get the values you expect? Now print out all the rows and columns of the board as strings. You should end up with 8 four letter words. Are there any real words shown? Add your total output as a comment in your gist.
Now write some driver code to access an individual coordinate in your boggle_board
object. Make this as simple as possible. Can you access the "k" character at row 3 column 2?
Release 3: Refactor
Release 4: Reflect
You just made a transition from procedural programming to object-oriented programming! How is the implementation different? What are the benefits to using the Object Oriented approach (even if it is a bit more code?) Make sure to include your reflection in your gist.
Release 6: Review
Write feedback for at least two other solutions!
###Create a #get_diagonal
method
Just like the #get_col
or #get_row
method, the #get_diagonal
method should return an array of values, but it will need 2 coordinates entered to define the diagonal. Error checking to make sure the coordinates are actually a diagonal would probably be a good idea.