Forked from YanKozlovskiy/gist:bec874afcae6e5a5d588
Created
November 3, 2014 03:43
-
-
Save radar/c57a824950599e95c435 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 Player | |
def initialize(name, health = 100, rank = 1) | |
@name = name.capitalize | |
@health = health | |
@rank = rank | |
end | |
def say_hello | |
puts "#{@name} has #{@health} health and #{@rank} rank." | |
self | |
end | |
def rank_up | |
@rank += 1 | |
puts "Ranked up! #{@name} now has a rank of #{@rank}!" | |
self | |
end | |
end | |
player1 = Player.new("joe") | |
player2 = Player.new("mike") | |
puts player2.say_hello.rank_up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment