From 8650124b5b8f7c276cf6983a09f96303f849b9c7 Mon Sep 17 00:00:00 2001 From: Quix Date: Thu, 28 Feb 2019 21:58:26 +0200 Subject: [PATCH] Added hero entity --- hero.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 hero.rb diff --git a/hero.rb b/hero.rb new file mode 100644 index 0000000..be97c4d --- /dev/null +++ b/hero.rb @@ -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 \ No newline at end of file