a problem wtih my loop!! please have a look !!
this is the first node for the program master mind
Actually i need to enter a string, then i need to check whether its of 4 characters and if all letters are in the liste( a,b,c,d,e,f)
until these 2 conditions are nt satisfied , i need to continue to accept strings from keyboard.
so here i did a lot of manipulations, i know tat some are useless, they r just to help me to understand much better
so if u can find a solution; please do help me , coz im really getting mad
thank you!!!
//*************************************************************************
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!MASTER MIND !!!!!!!!!!!!!!!!!!!!!!!!!!!!
//*************************************************************************
int nbEchecs=0,nbpresent=0,j;int nbtrouves =0;int nblettre;int
nIndices=0;int i,c=0,k=0,h=0,p=0;int nbtrouves2=0, nbtrouves1 =0;
boolean bgagne,bAbsent;bgagne=false;
boolean present,pluslong=false;
String cmot1,cLettre;
char [] cDevine =newchar[10];
char [] cLettres =newchar[26];
char [] couleurs ={'A','B','C','D','E','F'};
BufferedReader clavier =new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Entrer la combinaison secrete a deviner avec le code A, B, C, D, E, F");
cmot1=clavier.readLine();
nblettre=cmot1.length();
cmot1=cmot1.toUpperCase();
cDevine = cmot1.toCharArray();
present=true;
//******** to check if it the colors are from a to f n length is 6
do
{
if(cmot1.length()!=4)
pluslong=true;
else
pluslong=false;
for(k=0;k<nblettre;k++)
for(int g=0;g<6;g++)
if(cDevine[k]!=couleurs[g])
c=c+1;
if(c>1)
present=false;
else
present=true;
if(present==false || pluslong==true)
{
System.out.println("Il y a plus que 4 characteres ou Vous avez rentrez une couleur qui nest pas valide!!!");
System.out.println("Recommencer, entrer une combinaison");
cmot1=clavier.readLine();
cmot1=cmot1.toUpperCase();
cDevine = cmot1.toCharArray();
nblettre=cmot1.length();
}
}while(present==true && pluslong ==false);

