public static int jabberwock(boolean frumious, boolean manxome, boolean uffish){ if (!frumious){ if (manxome) { if (uffish){ return JUBJUB_BIRD; } else if (!manxome) { return BANDERSNATCH; } else{ return JUBJUB_BIRD; } } else { return JUBJUB_BIRD; } } else if (!uffish){ if (!manxome){ return BANDERSNATCH; } } else if(!manxome){ return JUBJUB_BIRD; } if (!(uffish || !manxome)) { return BANDERSNATCH; } return JUBJUB_BIRD; } Answer: public static int jabberwock( boolean frumious, boolean manxome, boolean uffish) {
if (!frumious && (manxome && uffish)) { return JUBJUB_BIRD; } else if (!frumious && (manxome && !manxome)) { return BANDERSNATCH; } else if (!frumious && !uffish) { return JUBJUB_BIRD; } else if (!uffish && !manxome) { return BANDERSNATCH; } else if (!manxome) { return JUBJUB_BIRD; } return JUBJUB_BIRD; }
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
haven't looked at the original code, just your answer
get rid of all the "return JUBJUB_BIRD; if blocks" and leave the final as the default combine the two return BANDERSNATCH; if blocks no idea if your code (answer) is accurate