//the arrays are searched through to find cats matching the criteria
for (int i = 0; i < noCats; i++)
{
if (identifyHairLength == hairLength[i])
{
con1 = "true";
}
else
{
con1 = "false";
}
here the value con1 should be updated to true as when testing both 'identifyHairLength' and 'hairLength[i]' are the same, but despite this con1 is still false??
System.out.println(identifyHairLength);
System.out.println(hairLength[i]);
System.out.println(con1);
if (catAges[i] >= 7 && identifyOldYoung == "old")
{
con2 = "true";
}
else if (catAges[i] < 7 && identifyOldYoung == "young")
{
con2 = "true";
}
else
{
con2 = "false";
}
//if the users criteria matches the current cat being searched then it is output to the user.
if (con1 == "true" && con2 == "true")
{
System.out.println("-" + catNames[i] + ", who is " + catAges[i]);
}
}
break;
}
Aucun commentaire:
Enregistrer un commentaire