Skip to content

Commit

Permalink
Added hero entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahontic committed Feb 28, 2019
1 parent 386a57f commit 8650124
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions hero.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class Hero
def initialize(name, health=100)
@name = name.capitalize
@health = health
end

def name
@name
end

def power_up
@health += 10
end

def power_down
@health -= 10
end

def hero_info
"#{@name}\'s health is #{@health}"
end
end

hero = Hero.new 'mike'
puts hero.name
puts hero.power_up
puts hero.power_down
puts hero.hero_info

0 comments on commit 8650124

Please sign in to comment.