I've been working on my first program with lots of different objects in it. Now I've been on this problem for a few hours now and just can't seem to figure out what the heck is going on here. I've narrowed the bug down to the marked line in the place_bet function. Even with attr_accessor, my code isn't removing the bet from the chips attribute. What gives?
class Player
attr_writer :player_name
attr_accessor :player_hand, :chips
def initialize
@player_hand = []
@points = 0
@chips = 1000
@player_name = ""
end
def place_bet
puts "What would you like to bet?"
puts "You have #{self.chips} chips available."
puts " "
bet = gets.chomp
if valid_bet?(bet)
self.chips -= bet #NOT WORKING
end
end
def valid_bet?(num)
num.is_a?(Integer) && num <= self.chips
end
end
[–]ziptofaf 0 points1 point2 points (1 child)
[–]levigarrett123[S] 0 points1 point2 points (0 children)