Move History

Fork Selected
  • 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 {
      
        @Test
        void test0True() {
          boolean[] bools = new boolean[3];
          
          assertEquals(false, Kumite.boolCheck(bools));
        }
      
        @Test
        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));
          }
        }
      
        @Test
        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));
          }
        }
      
        @Test
        void test3True() {
          boolean[] bools = new boolean[]{true, true, true};
          
          assertEquals(true, Kumite.boolCheck(bools));
        }
    }
    
  • 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;
    • }
    • }