I need to make a program in ruby to generate a robot name like KU765 or NG274 style and to store them and check it to avoid repetition. I also need to make a "reset" method to delete all stored names and start again. This program is not working for some reason. I hope somebody helps me to find the mistake. Thanks a lot.
class Robot
attr_accessor :named , :stored_names , :rl
def self.name
new.name
end
@@rl = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def name
named = ""
named << @@rl[rand(26).to_i]
named << @@rl[rand(26).to_i]
named << rand(100..999).to_s
named.save_name
named.check_name
end
def save_name
stored_names = []
stored_names << named
end
def check_name
stored_names.uniq!
end
def reset
stored_names = Array.new
end
end