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
def generate_players(number_players, chips): | |
#creates dictionary of players, starting with the dealer (the 0th player). | |
#0th item in list is the value of the hand, | |
#1st is the actual 1st and 2nd cards held | |
#2nd is number of high aces | |
#3rd is the number of chips left | |
players = [[0, [None,None], 0, 999999999999]] | |
i = 1 | |
while i<= number_players: | |
# player number: value, cards in hand, number of high aces, chips |
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
def test(x) | |
print x | |
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 Player | |
attr_accessor :value, :cards, :chips | |
@@num_players = 0 | |
def initialize(chips) | |
@value = 0 #numeric value of current hand | |
@cards = [] #space for first two cards | |
@high_aces = 0 | |
@chips = chips | |
@@num_players += 1 |
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 Player | |
attr_accessor @@num_players | |
@@num_players = 0 | |
def initialize(chips) | |
@value = 0 #numeric value of current hand | |
@cards = [] #space for first two cards | |
@high_aces = 0 | |
@chips = chips | |
@@num_players += 1 |
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 Player | |
@@num_players = 0 | |
def initialize(chips) | |
@value = 0 #numeric value of current hand | |
@cards = [nil,nil] #space for first two cards | |
@high_aces = 0 | |
@chips = chips | |
@@num_players += 1 | |
end | |
#here we would define player-specific methods |
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 Player | |
attr_accessor @@num_players | |
@@num_players = 0 | |
def initialize(chips) | |
@value = 0 #numeric value of current hand | |
@cards = [nil,nil] #space for first two cards | |
@high_aces = 0 | |
@chips = chips | |
@@num_players += 1 |
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 Parent | |
def initialize | |
@type = "parent" | |
puts "Initializing #{type}" | |
end | |
def parent_method1 | |
puts "this is a parent method" | |
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 Parent | |
def initialize | |
@type = "parent" | |
puts "Initializing parent. What're you gonna do about it?" | |
end | |
end | |
Parent.new | |
#=> Initializing parent. What're you gonna do about it? |
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 FosterParent | |
def foster_method | |
puts "watching soccer" | |
end | |
end | |
class Child | |
def initialize | |
@type = "child" # same as before | |
super() #same as before |
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 FosterParent | |
def foster_method | |
puts "watching soccer" | |
end | |
end | |
class Child | |
def initialize | |
@type = "child" # same as before | |
super() #same as before |
OlderNewer