public class PhraseOMatic2 {
public static void main (String[] args) {
String[] wordListOne = {"30000-килограммовый", "умопомрачительный", "няшный"};
String[] wordListTwo = {"трансцендентный", "великорусский"};
String[] wordListThree = {"КРЫМНАШ", "ябатинг", "пук"};
int oneLength = wordListOne.length;
int twoLength = wordListTwo.length;
int threeLength = wordListThree.length;
int rand1 = (int) (Math.random() * oneLength);
int rand2 = (int) (Math.random() * twoLength);
int rand3 = (int) (Math.random() * threeLength);
String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
while (phrase != wordListOne[0] + " " + wordListTwo[1] + " " + wordListThree[2]) {
System.out.println("Всё, что на нужно - это " + phrase);
int rand4 = (int) (Math.random() * oneLength);
int rand5 = (int) (Math.random() * twoLength);
int rand6 = (int) (Math.random() * threeLength);
phrase = wordListOne[rand4] + " " + wordListTwo[rand5] + " " + wordListThree[rand6];
}
}
}
Настя Макарошка
1 уровень
Это генератор фразы. Почему программа не заканчивается? Хочу чтобы она перебирала возможные варианты, а затем закончилась на фразе: 30000-килограммовый великорусский пук. Только начинаю изучать java
Решен
Комментарии (2)
- популярные
- новые
- старые
Для того, чтобы оставить комментарий Вы должны авторизоваться
KIRAExpert
15 апреля 2021, 00:40полезный
!= не подойдет, подробности в статье Как сравнить строки
+1
Настя Макарошка
15 апреля 2021, 09:07
Спасибо
0