Instantiation Nation


#1

Well, I'm definitely doing something wrong although this passed the last exercise and I thought all I was supposed to do was add the my_computer variable as shown in the hint...here's my code...anyone?

class Computer
def Computer.get_users
@@users = {}
def initialize(username, password)
@username = username
@password = password
@files = files
@@users[username] = password
def create(filename)
time = Time.now
@files[filename] = time
puts "#{filename} was created by #{@username} at #{time}."
end
end
end

my_computer = Computer.new("Hoho", 1950)


#2

i got into the same problem with error message"uninitialized class variable @@user in Context::Computer". anyone?


#3

@artsdottir

class Computer # @@users = {};

def Computer.get_users

@@users = {}
def initialize(username, password)
@username = username
@password = password
@files = files # <---This wrong
@@users[username] = password # <----This not in the right place
def create(filename)
time = Time.now
@files[filename] = time
puts "#{filename} was created by #{@username} at #{time}."
end
end
end

my_computer = Computer.new("Hoho", 1950)
Look back at 1/7 , your syntax is all wrong!

:cry: