19. Inheriting a fortune, help!


#1

Hello, I am currently having some problems with my code, I dunno what is wrong. It keps saying there is a mismatch in superclass for Email class. Thanks in advance!

Okay, I cannot upload an image, I dunno how its done...here is the code...

class Message 
    @@messages_sent = 0
    def initialize(from, to)
        @from = from
        @to = to
        @@messages_sent +=1
    end
end

my_message = Message.new("Ana", "Joao")

class  Email < Message
    def initialize(subject)
        @subject = subject
    end
end

#2

I had the same problem. Here is the solution to it:
1. Cut all the code out.
2. Click to 'Reset the Code"
3. Refresh the page
4. Paste your code back
5. Press 'Run"

Voila!
Hope that helps! =)


#3

Thanks :slight_smile:

It seems if I put a class variable emal, it also Works.
I didn't know classes were obliged to have a class variable!
THis is done!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.