-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWord
120 lines (89 loc) · 3.16 KB
/
Word
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//<Word> Random String creator
//CSIS312 - <Assignment4>
//Citations if necessary>--
import java.security.SecureRandom;
public class Word {
//variables
private String article = null;
private String noun = null;
private String verb = null;
private String preposition = null;
private String article2 = null;
//constructor
public Word(String article, String noun, String verb, String preposition, String article2){
this.article = article;
this.noun = noun;
this.verb = verb;
this.preposition = preposition;
this.article2 = article2;
}
//getters
public String getArticle(){
return article;
}
public String getNoun(){
return noun;
}
public String getVerb() {
return verb;
}
public String getPreposition(){
return preposition;
}
public String getArticle2(){
return article2;
}
public static void main(String[] args) {
//class required sentence
System.out.println("Lisa Tidball - Assignment 4");
//arrays
String[] article = {"the", "a", "one", "some", "any"};
String[] noun = {"boy", "girl", "dog", "town", "car"};
String[] verb = {"drove", "jumped", "ran", "walked", "skipped"};
String[] preposition = {"to", "from", "over", "under", "on"};
String[] article2 = {"and"};
//random generator
SecureRandom randomNumbers = new SecureRandom();
//for loop to go through and create sentences
for(int getSentence = 0; getSentence < 20; getSentence++){
StringBuilder sentence = new StringBuilder();
int randomArticle = randomNumbers.nextInt(article.length-1);
int randomNoun = randomNumbers.nextInt(noun.length-1);
int randomVerb = randomNumbers.nextInt(verb.length-1);
int randomPreposition = randomNumbers.nextInt(preposition.length-1);
String randomA = article[randomArticle];
randomA = randomA.substring(0, 1).toUpperCase() + randomA.substring(1);
sentence.append(randomA).append(" ")
.append(noun[randomNoun]).append(" ")
.append(verb[randomVerb]).append(" ")
.append(preposition[randomPreposition]).append(" ")
.append(noun[randomNoun]).append(" ")
.append(article2[0]).append(" ")
.append(noun[randomNoun]).append(".");
System.out.println(sentence.toString());
}//end for loop
}//end main
}//end class Word
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package word;
/**
*
* @author lirby
*/
public class Sentence {
//variable
StringBuilder Word;
//constructor
public Sentence(StringBuilder Word){
this.Word = Word;
}
//getter
public StringBuilder getSentence(){
StringBuilder sentence = null;
return sentence;
}
}