Lab6a Explain
Lab6a Explain
import java.util.Random;
int index = 0;
index = r1.nextInt(str.length()-1);
// then randomly creating a integer, for index value of string, for letter to
replace by *
phrase.replace(index,index+1,"*");
return phrase;
then in that case we can use for loop to traverse thru out length and replace all
the charactars
public static int placeLocator(char input, String phraseSolution, StringBuilder
phrase)
int place;
int x = 0;
for(i=0;i<phraseSolution.length();i++)
if(input == phraseSolution.charAt(i))
//case2 : if repeated characters not to be replace in one go. in that case we need
to create the array of bool values . this array will be used to create the track of
index which is changed....
for(int i=0;i<phraseSolution.length();i++)
array1[i] = True
}
}