Good day to everyone! There is a quote generator made with Shoes.
@think.click do
@noun_nominative.shuffle
@base.shuffle
@thought.replace(@base.sample)
end
@noun_nominative =
[
"word1", "word2", "word3", "word4",
"word5", "word6", "word7", "word8"
]
@noun_accusative =
[
"word1", "word2", "word3"
]
@base =
[
@noun_nominative.sample.capitalize + "regular quote",
"Regular quote" + @noun_nominative.sample,
"Regular quote" + @noun_accusative.sample,
"Regular quote" + @noun_accusative.sample,
@noun_nominative.sample.capitalize + "regular quote",
"And another one base for a quote"
]
It simply replaces phrases in base array with random words from noun_nominative and noun_accusative, showing a new quote every time button "think" is clicked.
The program should make a brand new quote with every click, however, it keeps showing the same phrases which were generated once. How could I make it regenerate the quotes without reopening the program?
Thank you for answering!
You need to generate random quote on each click, rather than pre-generating them at app startup. This should be the laziest change to do what you want:
It is, of course, rather wasteful. It generates all possible quotes and discards all but one. If that's a concern, fixing that would be your homework. :)