Created
April 23, 2015 21:36
-
-
Save eddroid/d7a2f96a99ce731f6f2e to your computer and use it in GitHub Desktop.
Reality Show C5: Shark Tank
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 SharkTank | |
attr_reader :sharks, :entrepreneur | |
def initialize | |
@sharks = [] | |
end | |
def add_shark(shark) | |
@sharks << shark | |
end | |
def add_entrepreneur(entrep) | |
@entrepreneur = entrep | |
end | |
def sharks_out? | |
@sharks.all? do |shark| | |
shark.check_pitch | |
end | |
end | |
def sharks_remaining | |
@sharks.reject do |shark| | |
shark.is_out | |
end.size | |
end | |
end | |
class Shark | |
attr_reader :name, :is_out | |
def initialize(name) | |
@name = name | |
end | |
def check_pitch | |
@is_out = [true, false].sample | |
end | |
end | |
class Entrepreneur | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
def pitch | |
end | |
end | |
def test | |
# can create world? | |
game = SharkTank.new | |
# can create shark? | |
mr_wonderful = Shark.new "Mr. Wonderful" | |
# shark has name? | |
puts mr_wonderful.name == "Mr. Wonderful" | |
# can add shark to world? | |
game.add_shark mr_wonderful | |
puts game.sharks == [mr_wonderful] | |
# can create 2nd shark (with name)? | |
mark_cuban = Shark.new "Mark Cuban" | |
puts mark_cuban.name == "Mark Cuban" | |
# can add 2nd shark to world? | |
game.add_shark mark_cuban | |
puts game.sharks == [mr_wonderful, mark_cuban] | |
# can create entrepreneur with name? | |
entrep = Entrepreneur.new "Wyncode" | |
puts entrep.name == "Wyncode" | |
# can add entrepreneur to world? | |
game.add_entrepreneur entrep | |
puts game.entrepreneur == entrep | |
# can entrepreneur pitch? | |
entrep.pitch | |
# can sharks go "out" after pitch? | |
all_out = game.sharks_out? | |
# are we "done" after all sharks go out? | |
puts "Done" if all_out | |
# can get number of remaining sharks? | |
puts "Sharks remaining: #{game.sharks_remaining}" | |
# can remaining shark negotiate with entrepreneur? | |
if game.sharks_remaining == 1 | |
# TODO: shark/entrep negotiate | |
end | |
end | |
test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment