-
Code public class Kumite { public static boolean boolCheck(boolean[] bools) { if (bools[0] && bools[1]) return true; if (bools[0] && bools[2]) return true; if (bools[1] && bools[2]) return true; return false; } }
Test Cases import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { void test0True() { boolean[] bools = new boolean[3]; assertEquals(false, Kumite.boolCheck(bools)); } void test1True() { boolean[] bools = new boolean[3]; for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { bools[j] = false; } bools[i] = true; assertEquals(false, Kumite.boolCheck(bools)); } } void test2True() { boolean[] bools = new boolean[3]; for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { bools[j] = true; } bools[i] = false; assertEquals(true, Kumite.boolCheck(bools)); } } void test3True() { boolean[] bools = new boolean[]{true, true, true}; assertEquals(true, Kumite.boolCheck(bools)); } }
Output:
-
Code - public class Kumite {
- public static boolean boolCheck(boolean[] bools) {
return bools[0] ? bools[1] || bools[2] : bools[1] && bools[2];- if (bools[0] && bools[1]) return true;
- if (bools[0] && bools[2]) return true;
- if (bools[1] && bools[2]) return true;
- return false;
- }
- }
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}