13. Imitating Multiple Inheritance


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/ruby-beginner-en-zfe3o/2/2?curriculum_id=5059f8619189a5000201fbcb

My code is correct according to code academy but Why doesnt I’m a swordsman" print twice when i run the code? Instead only the message nil.

```

Create your module here!

module MartialArts
def swordsman
puts “I’m a swordsman”
end
end

class Ninja
include MartialArts

def initialize(clan)
@clan = clan
end
end

class Samurai
include MartialArts

def initialize(shogun)
@shogun = shogun
end
end

<do not remove the three backticks above>

#2

@supasuma,
You have defined your classes
but then you have to Instantiate those classes
meaning you have to create a so-called Instance
like

module MartialArts
    def swordsman
        puts "I'm a swordsman"
    end
end

class Ninja
include MartialArts

  def initialize(clan)
    @clan = clan
  end
  def get_clan
    @clan
  end
end
class Samurai
include MartialArts

  def initialize(shogun)
    @shogun = shogun
  end
  def get_shogun
    @shogun
  end
end
#=======================
# now create Instances
#=======================
Samurai1 = Samurai.new("Shogun-Leon")
Samurai1.swordsman
puts Samurai1.get_shogun
puts "=========================="
aNinja= Ninja.new("Leon-clan")
puts aNinja.get_clan
aNinja.swordsman

this will create the output

I'm a swordsman
Shogun-Leon
==========================
Leon-clan
I'm a swordsman