• Post Reply Bookmark Topic Watch Topic
  • New Topic

randomize sentances  RSS feed

 
Enos Winder
Greenhorn
Posts: 18
C++ Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have code yet. I have a question. I want to write several sentences. I then want to randomize those sentences so that my program will spit out a sentence at random. I am thinking arrays would do this? Just not sure and need a little input to point me in the right direction.
 
Simon Roberts
Author
Ranch Hand
Posts: 182
9
Java Linux Netbeans IDE Scala Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, you could probably have arrays (or Lists) of nouns, verbs, adjectives (one array/List of each), and pick items from them at random, then use those items to fill out a template of Subject-noun verb adjective object-noun.

HTH
Simon
 
Stephan van Hulst
Saloon Keeper
Posts: 7974
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have pre-made sentences, you can dump them all in a List, and then shuffle the list.
 
Enos Winder
Greenhorn
Posts: 18
C++ Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just figured that out. Thanks. I am going to put my sentences in an array then shuffle the array. I appreciate the help.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably much easier to shuffle a List because you can use this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!