Guest User

Untitled

a guest
Jan 31st, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. class Machine
  2. @@users = {}
  3.  
  4. def initialize(username, password)
  5. @username = username
  6. @password = password
  7. @@users[username] = password
  8. @files = {}
  9. end
  10.  
  11. def create(filename)
  12. time = Time.now
  13. @files[filename] = time
  14. puts "#{filename} was created by #{@username} at #{time}."
  15. end
  16.  
  17. def Machine.get_users
  18. @@users
  19. end
  20. end
  21.  
  22. my_machine = Machine.new("eric", 01234)
  23. your_machine = Machine.new("you", 56789)
  24.  
  25. my_machine.create("groceries.txt")
  26. your_machine.create("todo.txt")
  27.  
  28. puts "Users: #{Machine.get_users}"
Add Comment
Please, Sign In to add comment