FAQ: Virtual Computer - Getting More Creative

This community-built FAQ covers the “Getting More Creative” exercise from the lesson “Virtual Computer”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Ruby

FAQs on the exercise Getting More Creative

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

There was a bug for me on this exercise - filenames password.txt and blastoff.txt were created and printed to the console but no code for this was in the editor.

2 Likes

ditto, ,but then when I ran the code again, nothing happened

2 Likes

can someone explain to me why this is not working??

thanks in advance??

class Computer

@@users = Hash.new

def initialize(username, password)
@username = username
@password = password
@files = Hash.new

@@users[username] = password
end

def create(filename)
time = Time.now
@files[filename] = time
puts “New file created by #{username}!”
end
end

2 Likes

Hello.

I believe I had the same issue as you. I was getting the red X of nope when I tried to run it, but got no explanation as to why. I looked bck over the example in the first part of the lesson and found the issue:

In the puts section at the end, it needs to be #{@username}, not #{username}.

4 Likes

yep, same error here. o.o

Hey guys! i need some help with this one :frowning:

class Computer
@@users={}
def initialize (username,password)
@username=username
@password=password
@files={}
@@user[username]=password
end

def create (filename)
time=Time.now
@files[filename]=time
puts “New file was created from #{username}”
end
end

thanks!!!

I had the same error.

def create (filename)
time=Time.now
@files[filename]=time
puts “New file was created from #{username}”
end
end

The create method doesn’t recognize username as a variable. You’d need to use @username from what I can tell.

If I am wrong, please someone correct me. :slight_smile:

1 Like

Are we supposed to have access to another .rb file in which new instances of our class Computer are created? If not, how are the two instances created and output to the terminal (as others describe above)?

My first attempt at running the code below resulted in duplicate puts statements. When running it a second/third/fourth time, the console didn’t print anything. In order to print it again, I had to copy the code, refresh the editor, paste the code, and run again. Voila! I reported these issues to Codecademy just now but wanted to share with y’all so you don’t think you’re missing something. Happy learning! :stuck_out_tongue_winking_eye:

class Computer
  def initialize(username, password)
    @username = username
    @password = password
    @files = Hash.new
    @@users[username] = password
  end

  @@users = Hash.new

  def create(filename)
    time = Time.now
    @files[filename] = time
    puts "Nicely done! #{@filename} was created by #{@name} on #{time}."
  end
end

1 Like

Next, inside create , add a new key/value pair to the @files hash. Use the filename key to store the value time .

IS IT CHINESE LANGUAGE, THANKS FOR CODECADEMY PRO TO BE SHORT ITS VERY HELPFULL!!!