我在.text文件中创建了一个madlib,现在我需要用用户输入替换名词,动词和形容词。这就是我所拥有的......
.txt文件 ---
"在第一次下雪的过程中,我开车了#34; [名词]"并被抓住了 惊喜!在驾驶我认为是一个" [adj]"卡车可以 通过任何事情,我发现自己" [动词]"在12英寸的雪中 漂移。那里是人与雪!我怎么会出去?我跳了起来 out和" [adv]"用于战斗。我和我...扫帚!我输了!"
.rb文件 ---
file = File.new("myfile.txt", "r")
#start collecting user input-----------------------------------------------------
#clear display area
Console_Screen.cls
#prompt user for input for noun--------------------------------
print %Q{Type a noun? (Press Enter) \n\n: }
#force user to press enter to continue
noun = STDIN.gets
#remove any extra characters appended to the string
noun.chomp!
noun = [noun]
#clear display area
Console_Screen.cls
#prompt user for input for verb-------------------------------
print %Q{Type a verb. (Press Enter) \n\n: }
#force player to press enter to continue
verb = STDIN.gets
#remove any extra characters appended to the string
verb.chomp!
#clear display area
Console_Screen.cls
#prompt user for input for adjective---------------------------------
print %Q{Type an adjective. (Press Enter) \n\n: }
#force user to press enter to continue
adj = STDIN.gets
#remove any extra characters appended to the string
adj.chomp!
#clear display area
Console_Screen.cls
#prompt user for input for adverb---------------------------------
print %Q{Type an adverb. (Press Enter) \n\n: }
#force user to press enter to continue
adv = STDIN.gets
#remove any extra characters appended to the string
adv.chomp!
#clear display area
Console_Screen.cls
#Time to tell the story!----------------------------------------
puts story
end