fork download
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.Random;
  4.  
  5. /**
  6.  * Created by tvoyamamka on 08.07.2014.
  7.  */
  8. public class RandomSentenceGen {
  9.  
  10. private String sentence;
  11.  
  12. public RandomSentenceGen() {
  13. ListOfWords.fillList();
  14. }
  15.  
  16. public String getSentence() {
  17. sentence = ListOfWords.getArticles()+
  18. ListOfWords.getFirstNouns()+
  19. ListOfWords.getVerbs()+
  20. ListOfWords.getArticles()+
  21. ListOfWords.getAdjective()+
  22. ListOfWords.getSecondNouns();
  23. return sentence;
  24. }
  25.  
  26. private static class ListOfWords {
  27. protected static List<String> articles = new ArrayList<String>();
  28. protected static List<String> firstNouns = new ArrayList<String>();
  29. protected static List<String> verbs = new ArrayList<String>();
  30. protected static List<String> secondNouns = new ArrayList<String>();
  31. protected static List<String> adjective = new ArrayList<String>();
  32. private static void fillList() {
  33. articles.add("a");
  34. articles.add("the");
  35. firstNouns.add("man");
  36. firstNouns.add("woman");
  37. firstNouns.add("mamka");
  38. firstNouns.add("erohin");
  39. firstNouns.add("harkach");
  40. verbs.add("retrieve");
  41. verbs.add("find");
  42. verbs.add("clear");
  43. verbs.add("hit");
  44. verbs.add("take");
  45. verbs.add("deserve");
  46. secondNouns.add("dick");
  47. secondNouns.add("car");
  48. secondNouns.add("dog");
  49. secondNouns.add("abu");
  50. secondNouns.add("shop");
  51. secondNouns.add("bar");
  52. secondNouns.add("foo");
  53. adjective.add("dirty");
  54. adjective.add("angry");
  55. adjective.add("unstable");
  56. adjective.add("real");
  57. adjective.add("inner");
  58. }
  59.  
  60. public static String getArticles() {
  61. return articles.get(new Random().nextInt(2))+" ";
  62. }
  63.  
  64. public static String getFirstNouns() {
  65. return firstNouns.get(new Random().nextInt(5))+" ";
  66. }
  67.  
  68. public static String getVerbs() {
  69. return verbs.get(new Random().nextInt(6))+" ";
  70. }
  71.  
  72. public static String getSecondNouns() {
  73. return secondNouns.get(new Random().nextInt(7))+" ";
  74. }
  75.  
  76. public static String getAdjective() {
  77. return adjective.get(new Random().nextInt(5))+" ";
  78. }
  79. }
  80. }
  81.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:8: error: class RandomSentenceGen is public, should be declared in a file named RandomSentenceGen.java
public class RandomSentenceGen {
       ^
1 error
stdout
Standard output is empty