Skip to main content
Code Review

Return to Question

added link; edited tags
Source Link
200_success
  • 145.5k
  • 22
  • 190
  • 479

I'm doing CodingBat exercisea CodingBat exercise and would like to learn to write code in the most efficient way. On this exercise, I was just wondering if there's a shorter way to write this code.

monkeyTrouble(true, true) → true
monkeyTrouble(false, false) → true
monkeyTrouble(true, false) → false
public boolean monkeyTrouble(boolean aSmile, boolean bSmile) {
 
 if (aSmile && bSmile) {
 return true;
 }
 
 if (!aSmile && !bSmile) {
 return true;
 }
 return false; 
}

I'm doing CodingBat exercise and would like to learn to write code in the most efficient way. On this exercise, I was just wondering if there's a shorter way to write this code.

monkeyTrouble(true, true) → true
monkeyTrouble(false, false) → true
monkeyTrouble(true, false) → false
public boolean monkeyTrouble(boolean aSmile, boolean bSmile) {
 
 if (aSmile && bSmile) {
 return true;
 }
 
 if (!aSmile && !bSmile) {
 return true;
 }
 return false; 
}

I'm doing a CodingBat exercise and would like to learn to write code in the most efficient way. On this exercise, I was just wondering if there's a shorter way to write this code.

monkeyTrouble(true, true) → true
monkeyTrouble(false, false) → true
monkeyTrouble(true, false) → false
public boolean monkeyTrouble(boolean aSmile, boolean bSmile) {
 
 if (aSmile && bSmile) {
 return true;
 }
 
 if (!aSmile && !bSmile) {
 return true;
 }
 return false; 
}
edited tags
Link
200_success
  • 145.5k
  • 22
  • 190
  • 479
Tweeted twitter.com/#!/StackCodeReview/status/419464679589945345
Make title represent the code, correct tags.
Source Link
rolfl
  • 98.1k
  • 17
  • 219
  • 419

Is there a shorter way to write this java code Simpler boolean truth table?

I'm doing CodingBat exercise and would like to learn to write code in the most efficient way. On this exercise, I was just wondering if there's a shorter way to write this code.

monkeyTrouble(true, true) → true
monkeyTrouble(false, false) → true
monkeyTrouble(true, false) → false
_____________
public boolean monkeyTrouble(boolean aSmile, boolean bSmile) {
 
 if (aSmile && bSmile) {
 return true;
 }
 
 if (!aSmile && !bSmile) {
 return true;
 }
return false; 
}

Is there a shorter way to write this java code?

I'm doing CodingBat exercise and would like to learn to write code in the most efficient way. On this exercise, I was just wondering if there's a shorter way to write this code.

monkeyTrouble(true, true) → true
monkeyTrouble(false, false) → true
monkeyTrouble(true, false) → false
_____________
public boolean monkeyTrouble(boolean aSmile, boolean bSmile) {
 
 if (aSmile && bSmile) {
 return true;
 }
 
 if (!aSmile && !bSmile) {
 return true;
 }
return false; 
}

Simpler boolean truth table?

I'm doing CodingBat exercise and would like to learn to write code in the most efficient way. On this exercise, I was just wondering if there's a shorter way to write this code.

monkeyTrouble(true, true) → true
monkeyTrouble(false, false) → true
monkeyTrouble(true, false) → false
public boolean monkeyTrouble(boolean aSmile, boolean bSmile) {
 
 if (aSmile && bSmile) {
 return true;
 }
 
 if (!aSmile && !bSmile) {
 return true;
 }
return false; 
}
Source Link
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /