jweinst1
1/7/2016 - 2:27 AM

basic inheritance in ruby

basic inheritance in ruby

class Pokemon
    def initialize(name, attack, defence)
        @name = name
        @attack = attack
        @defence = defence
    end
    def damage(amount)
        @defence -= amount
    end
    def raiseatk(amount)
        @attack += amount
    end
end


class Charmander < Pokemon
    def flamethrow(oppoent)
        opponent.damage(3)
    end
end