I've created a 2d array of characters. I want to replace the character '.' with the character 'd' but randomly, also having the ability to not replace the character '#'. Here's my code. I know I haven't programmed it to replace anything, but its the foundations of it. I'm really stuck so any help is appreciated! Thank you.
Random randomGenerator = new Random();
for(int row=0; row<mapp.length; row++){
for(int column=0; column<mapp[row].length; column++){
int randomIndex = randomGenerator.nextInt(mapp.length);
char[] options = {'d'};
mapp[row][column] = options[randomIndex];
System.out.print(mapp[row][column]);
}
System.out.println();
}
Aucun commentaire:
Enregistrer un commentaire