Created
September 16, 2010 12:47
-
-
Save hackervera/582360 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Child | |
| @@name = "baby" | |
| def name | |
| return @@name | |
| end | |
| end | |
| class OtherChild | |
| @@name = "baby" | |
| def name | |
| return @@name | |
| end | |
| end | |
| class Adult < Child | |
| def initialize | |
| @@name = "Sleeper Agent!" | |
| end | |
| end | |
| class Main | |
| @babies = []; | |
| def self.cry | |
| @babies.each { |baby| | |
| puts baby.name | |
| } | |
| end | |
| def self.addBaby(babe) | |
| @babies << babe | |
| end | |
| end | |
| 10.times { | |
| if rand*10 < 3 | |
| Main.addBaby Child.new | |
| end | |
| Main.addBaby OtherChild.new | |
| } | |
| Main.cry | |
| otherDude = Adult.new | |
| puts "\n\n" | |
| Main.cry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment