Created
May 7, 2010 13:11
-
-
Save geapi/393399 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 SliceOfCake | |
@@totalSlices = 0 | |
def initialize | |
@@totalSlices +=1 | |
end | |
def getNumberOfSlices | |
if(@@totalSlices == 0) | |
"sorry no slices yet" | |
elsif (@@totalSlices == 1) | |
"there is #{@@totalSlices} slice of cake" | |
else | |
"there are #{@@totalSlices} slices of cake" | |
end | |
end | |
end | |
slice = SliceOfCake.new | |
slice2 = SliceOfCake.new | |
puts slice.getNumberOfSlices #=> there are 2 slices of cake | |
puts slice2.getNumberOfSlices #=> there are 2 slices of cake |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment