Problem:
The parameter weekday is true if it is a weekday, and
the parameter vacation is true if we are on vacation. We sleep in if it
is not a weekday or we're on vacation. Return true if we sleep in.
Test cases:
sleepIn(false, false) → true sleepIn(true, false) → false sleepIn(false, true) → true
Solution:
public boolean sleepIn(boolean weekday, boolean vacation) { if (!weekday || vacation) { return true; } return false; we just put the return-false last, or could use an if/else. }
No comments:
Post a Comment