I am writing a mad libs program for fun and to just program something. The program itself is pretty straight forward, but I find myself resorting to several concatenations due to the nature of the game where you place user given words into a sentence. Is there an elegant work around to resort to less concatenations or even eliminate them for something more efficient? I know in the end it will make no difference if I use concatenations or not, but I am curious if there is a more elegant way to write this program.
Update: I am using java, but if there is a general solution to escaping concatenation that would be appreciated too.
One solution might be to write out your whole mad libs file and put in special tokens that need to be replaced by the words that are chosen.
Then you can use for example:
String.replace('${NOUN1}', noun1)for all the words.