Skip to content
Permalink
Browse files

Here are the Wizard Ninja Samurai and Dog ad Dragon assignments.

  • Loading branch information...
Mmgfrog committed Oct 5, 2016
1 parent 477bacc commit 53140b2088752f2e1b932d69b2b17ae9f8b863db
@@ -0,0 +1,20 @@
class Human
attr_accessor :strength, :intelligence, :stealth, :health
def initialize
@strength = 3
@stealth = 3
@intelligence = 3
@health = 100
end
def attack(victim)
if victim.class.ancestors.include?(Human)
puts "Attacking!"
victim.health -= 10
else
puts "Don't attack non-humans!"
end
end
end



@@ -0,0 +1,17 @@
require_relative "human"
require_relative "wizard"
require_relative "samurai"
class Ninja < Human
def initialize
super
@stealth = 175
end
def steal(object)
object.health -= 10
@health += 10
end
def get_away
@health -= 15
end
end

@@ -0,0 +1,25 @@
require_relative "human"
require_relative "wizard"
require_relative "ninja"
class Samurai < Human
@@count = 0
def initialize
super
@health = 200
@@count += 1
end
def death_blow(victim)
victim.health = 0
end
def meditate
@health = 200
end
def how_many
puts @@count
end
end





@@ -0,0 +1,18 @@
require_relative "human"
require_relative "ninja"
require_relative "samurai"
class Wizard < Human
def initialize
super
@health = 50
@intelligence = 25
end
def heal
@health += 10
return self
end
def fireball(attacker)
attacker.health -= 20
end
end

@@ -0,0 +1,13 @@
require_relative mammal
class Dog < Mammal
def pet
@health += 5
end
def walk
@health -= 1
end
def run
@health += 10
end
end
puts Dog.new.walk(3).run(2).pet(1).display_health
@@ -0,0 +1,23 @@
require_relative "mammal"
class Dragon < Mammal
def initialize
@health = 170
end
def fly
@health -= 10
return self
end
def attack_town
@health -= 50
return self
end
def eat_humans
@health += 20
return self
end
def display_health
puts "This is a dragon!"
super
end
end
puts Dragon.new.attack_town.attack_town.attack_town.eat_humans.eat_humans.fly.fly.display_health
@@ -0,0 +1,12 @@
class Mammal
attr_accessor :alive, :health
def initialize(alive, health)
@alive=True
puts "I am alive!"
@health=150
self
end
def display_health
puts "The health score is #{@health}."
end
end

0 comments on commit 53140b2

Please sign in to comment.
You can’t perform that action at this time.