编写一个采用随机函数生成句子的游戏。现在有4个字符串数组:artilce、noun、verbpreposition,它们的内容分别是: the、a、one、some、any; boy、girl、dog、town、car; drove、jumped、ran、walked、skipped; to、from、over、under、on。 依照句法要:article+noun+verb+prepsition+article+noum,编写程序以产生20句子。
编写一个采用随机函数生成句子的游戏。现在有4个字符串数组:artilce、noun、verbpreposition,它们的内容分别是: the、a、one、some、any; boy、girl、dog、town、car; drove、jumped、ran、walked、skipped; to、from、over、under、on。 依照句法要:article+noun+verb+prepsition+article+noum,编写程序以产生20句子。
你还动动脑子吧!
+ noun[(int) (Math.random() * noun.length)] + " "
+ verb[(int) (Math.random() * verb.length)] + " "
+ prepostion[(int) (Math.random() * prepostion.length)]; StringBuffer buffer = new StringBuffer(s);
buffer.setCharAt(0, Character.toUpperCase(s.charAt(0))); str[i] = buffer.toString() + ".\n";
outputArea.append(str[i]);
这个给你整个程序就给了~~哎,好好学习才素王道