Created
January 11, 2013 07:05
-
-
Save kennyt/4508584 to your computer and use it in GitHub Desktop.
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
## | |
## | |
## | |
# Inside the Hangman class : | |
# move the attr_accessors to the beginning of the method | |
# also, why have attr_accessors when you introduce each of the instance variables with def initialize? | |
attr_accessor :secret_word, :dictionary_words, :player_string, :word_size_floor, :word_size_ceiling, | |
:incorrect_guesses, :correct_guesses | |
# put this below attr_accessors at the beginning | |
def initialize(secret_word_generating_player, guessing_player, | |
quantity_wrong_guesses = 15, word_size_floor = 5, word_size_ceiling = 25) | |
@secret_word = [] | |
@dictionary_words = {} | |
@correct_guesses = [] | |
@incorrect_guesses = [] | |
@current_guess = "" | |
@quantity_wrong_guesses = quantity_wrong_guesses | |
@dict_filename = "5desk.txt" | |
@word_size_floor = word_size_floor | |
@word_size_ceiling = word_size_ceiling | |
@secret_word_generating_player = secret_word_generating_player | |
@guessing_player = guessing_player | |
@secret_word_generating_player.hangman_game = self | |
@guessing_player.hangman_game = self | |
end | |
## in mastermind | |
class Mastermind | |
# these attr_readers can safely be removed from your code. | |
attr_reader :winning_colors, :board, :board_hints, :colors | |
def victory? | |
@board.last == @winning_colors if @board.size > 0 # I believe "if @board.size > 0" is uneccessary. | |
# Just have : @board.last == @winning_colors | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment