Ruby 与要删除的方案关联的模块。Re。代码的第二部分-scheme\u exists类似于module\u exists,只是它检查方案是否存在,而不是模块是否存在。。。方案和模块是两个不同的东西。@Someone2088代码是相同的,只是映射不同。相同的代码。
Ruby 与要删除的方案关联的模块。Re。代码的第二部分-scheme\u exists类似于module\u exists,只是它检查方案是否存在,而不是模块是否存在。。。方案和模块是两个不同的东西。@Someone2088代码是相同的,只是映射不同。相同的代码。,ruby,Ruby,与要删除的方案关联的模块。Re。代码的第二部分-scheme\u exists类似于module\u exists,只是它检查方案是否存在,而不是模块是否存在。。。方案和模块是两个不同的东西。@Someone2088代码是相同的,只是映射不同。相同的代码。你不一定要相信或理解我说的话,但最终如果你想让其他人能够阅读你的代码,你需要做大量的修改。现在真的很难摸索。对不起,你说的地图是什么意思? def self.add_module # schemes = {} scheme_exists =
与要删除的方案关联的模块。Re。代码的第二部分-
scheme\u exists
类似于module\u exists
,只是它检查方案是否存在,而不是模块是否存在。。。方案和模块是两个不同的东西。@Someone2088代码是相同的,只是映射不同。相同的代码。你不一定要相信或理解我说的话,但最终如果你想让其他人能够阅读你的代码,你需要做大量的修改。现在真的很难摸索。对不起,你说的地图是什么意思?
def self.add_module
# schemes = {}
scheme_exists = false
add_another_scheme = true
# module_exists = false
add_another_module = true
while add_another_scheme
print "Enter scheme name: "
scheme_name = gets
$schemes.has_key?(scheme_name.chop) ? scheme_exists = true : scheme_exists = false
if !scheme_exists
$schemes[scheme_name.chop] = []
puts "Scheme #{scheme_name.chop} has been added to the system"
elsif
scheme_exists = true
puts "This scheme has already been added"
end
while add_another_module
print "Enter module name: "
module_name = gets
$schemes[scheme_name.chop].include?(module_name.chop) ? true : $schemes[scheme_name.chop] << module_name.chop
# puts "Module #{module_name.chop} has been added to #{scheme_name.chop}"
# 22/08/2012 at 14:15 Now need to read in each module's unique identifier and year it belongs to
print "Enter module ID: "
$module_ID =gets
$schemes[scheme_name.chop].include?($module_ID.chop) ? true : $schemes[scheme_name.chop] << $module_ID.chop
$schemes.has_key?($module_ID.chop) ? module_exists = true : module_exists = false
print "Enter the academic year to which the module belongs: "
module_year = gets
$schemes[scheme_name.chop].include?(module_year.chop) ? true : $schemes[scheme_name.chop] << module_year.chop
if !$module_exists
$schemes[$module_ID.chop] = []
puts "Module #{$module_ID.chop} : #{module_name.chop} has been added to #{scheme_name.chop} for the year #{module_year}"
elsif
$module_exists = true
puts "A module with this ID has already been added to the scheme, please check if the module already exists, or choose another ID "
else
# puts "Module #{module_name.chop}, #{module_ID.chop} has been added to #{scheme_name.chop} for the year #{module_year}"
end
# puts "Module #{module_name.chop}, #{module_ID.chop} has been added to #{scheme_name.chop}"
print "Add another module? "
ask_if_user_wants_to_add_another_module = gets
if(ask_if_user_wants_to_add_another_module.chop == "y" or ask_if_user_wants_to_add_another_module == "yes")
add_another_scheme = false
else if(ask_if_user_wants_to_add_another_module.chop != "y" or ask_if_user_wants_to_add_another_module != "yes")
Application.main_menu
end
end
end
def self.remove_module
print "Which scheme would you like to remove a module from? "
scheme_name = gets
$schemes.has_key?(scheme_name.chop) ? scheme_exists = true : scheme_exists = false
if !scheme_exists
$schemes[scheme_name.chop] = []
puts "Scheme #{scheme_name.chop} doesn't exist"
else
scheme_exists = true
puts "Which module would you like to remove from #{scheme_name.chop}?"
$module_ID = gets
if !$module_exists
$schemes[$module_ID.chop] = []
puts "Module #{$module_ID.chop} : does not exist in #{scheme_name.chop} "
else
module_exists = true
puts "Module #{$module_ID.chop} has been removed from #{scheme_name.chop} "
# puts "Module #{module_name.chop}, #{module_ID.chop} has been added to #{scheme_name.chop} for the year #{module_year}"
end
end
end
$schemes.has_key?(scheme_name.chop) ? scheme_exists = true : scheme_exists = false
# Did you mean:
scheme_exists = $schemes.has_key?(scheme_name.chop)
if !scheme_exists
$schemes[scheme_name.chop] = []
puts "Scheme #{scheme_name.chop} doesn't exist"
else
scheme_exists = true
# ...