Lab 3 Tests

Run Settings
LanguageRuby
Language Version
Run Command
puts rock.compare_to('Rock')[0] class Element attr_accessor :name @@result_strings = ['Scissors cut Paper', 'Paper covers Rock', 'Rock crushers Lizard', 'Lizard poisons Spock', 'Spock smashes Scissors', 'Scissors decapitate Lizard', 'Lizard eats Paper', 'Paper disproves Spock', 'Spock vaporizes Rock', 'Rock crushes Scissors'] @@outcome_strings = ['Win', 'Lose', 'Tie'] def initialize(name) @name = name end def compare_to(element) fail "This method should be overridden" end end class Rock < Element def compare_to(element) if self.class.name == element result = 'Rock equals Rock' outcome = @@outcome_strings[2] return result, outcome else result = @@result_strings.find { |val| val.include?(self.class.name) and val.include?(element) } end case result.split.first when self.class.name outcome = @@outcome_strings[0] else outcome = @@outcome_strings[1] end return result, outcome end end rock= Rock.new('Rock') puts rock.compare_to('Paper')[0]
Editor Settings
Theme
Key bindings
Full width
Lines