#when generating a word - consonants are not displayed and the code occurs 2 times

4 messages · Page 1 of 1 (latest)

elder parrot
#

package org.kadso567kcxg;
import java.util.Random;
import java.util.Scanner;

public class GenNick {
Scanner scan = new Scanner(System.in);
Random random = new Random();
public int l = 0;
public String name;
public boolean tog = true;
public GenNick() {
edit();
do {
name = gen(l);
System.out.println("\n"+ name);
String m;
System.out.print("Выберете действие (дальше/изменить/остановить) [C/E/S]: ");
m = scan.nextLine();
switch (m) {
case "C" :
tog = true;
break;
case "E" :
edit();
break;
case "S":
tog = false;
break;
case "c" :
tog = true;
break;
case "e" :
edit();
break;
case "s":
tog = false;
break;
}
}while (tog);
}
public void edit() {
System.out.print("ВВедите длинну ника: ");
l = scan.nextInt();
}
public String gen (int l) {
char[] sogl = new char[]{'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm','n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z'};
char[] glas = new char[]{'a','e','i', 'o', 'u', 'y', };
char[] name = new char[l];
for(int i = 0; i < l; i++) {
int sl = random.nextInt(20);
int g = random.nextInt(6);
int r = random.nextInt(2);
if (r == 1) {
name[i] = glas[g];
}
else if (r == 2) {
name[i] = sogl[sl];
}
}
return new String(name);
}
}

tardy pythonBOT
#

This post has been reserved for your question.

Hey @elder parrot! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

elder parrot