save file to disk java

Solutions on MaxInterview for save file to disk java by the best coders in the world

showing results for - "save file to disk java"
Magdalena
26 Jan 2018
1public class Test {
2
3   static final String[] conjunction = { "and", "or", "but", "because"};
4
5   static final String[] proper_noun = { "Fred", "Jane", "Richard Nixon","Miss America"};
6
7   static final String[] common_noun = { "man", "woman", "fish", "elephant", "unicorn"};                                  
8
9   static final String[] determiner = { "a", "the", "every", "some"};
10
11   static final String[] adjective = { "big", "tiny", "pretty", "bald"};
12
13   static final String[] intransitive_verb = { "runs", "jumps", "talks", "sleeps"};
14
15   static final String[] transitive_verb = { "loves", "hates", "sees", "knows", "looks for", "finds"};
16
17  
18
19  public static void main(String[] args) {
20
21      while (true) {
22
23         randomSentence();
24
25      System.out.println(".\n");
26
27         try {
28
29             Thread.sleep(3000);
30
31         }
32
33         catch (InterruptedException e) {
34
35         }
36
37      }
38
39   }
40
41   static void randomSentence() {
42
43      randomNounPhrase();
44
45              randomVerbPhrase();
46
47      if (Math.random() > 0.75) {
48
49              System.out.print(" " + randomItem(conjunction));
50
51              randomSentence();
52
53      }
54
55   }
56
57   static void randomNounPhrase() {
58
59          if (Math.random() > 0.75)
60
61             System.out.print(" " + randomItem(proper_noun));
62
63          else
64
65          {
66
67             System.out.print(" " + randomItem(determiner));
68
69             if (Math.random() > 0.5)
70
71         System.out.print(" " + randomItem(adjective)+".");
72
73                System.out.print(" " + randomItem(common_noun));
74
75                 if (Math.random() > 0.5){
76
77                      System.out.print(" who" );
78
79                      randomVerbPhrase();
80
81                 }
82
83          }
84
85     }
86
87      static void randomVerbPhrase() {
88
89          if (Math.random() > 0.75)
90
91             System.out.print(" " + randomItem(intransitive_verb));
92
93                else if (Math.random() > 0.50) {
94
95                        System.out.print(" " + randomItem(transitive_verb));
96
97                        randomNounPhrase();
98
99                }
100
101                else if (Math.random() > 0.25)
102
103                    System.out.print(" is " + randomItem(adjective));
104
105                else {
106
107                    System.out.print(" believes that");
108
109                    randomNounPhrase();
110
111                    randomVerbPhrase();
112
113                }
114
115       }
116
117   static String randomItem(String[] listOfStrings){
118
119       return listOfStrings[(int)(Math.random()*listOfStrings.length)];
120
121   }
122
123}
similar questions
queries leading to this page
save file to disk java