diff --git a/src/main/java/LightSwitcher.java b/src/main/java/LightSwitcher.java index 4499c39..b169a69 100644 --- a/src/main/java/LightSwitcher.java +++ b/src/main/java/LightSwitcher.java @@ -13,15 +13,14 @@ public class LightSwitcher { * NOTE: If the initial state of a switch is already turned on, do not turn it off. */ public static int turnOnSwitches(int switches, int switchesToTurnOn) { - + return switches | switchesToTurnOn; } - /** * Take a given input of switches and turn them all to on. * Remember to use bit notation (0bxxxxxxxx) and a bit operator. */ public static int turnOnAllSwitches(int switches) { - + return switches | 0b11111111; } /** @@ -30,7 +29,7 @@ public static int turnOnAllSwitches(int switches) { * And a '1' in a position in 'switchesToTurnOff' means to turn that switch to off. */ public static int turnOffSwitches(int switches, int switchesToTurnOff) { - + return switches & (~switchesToTurnOff); } /** @@ -38,7 +37,7 @@ public static int turnOffSwitches(int switches, int switchesToTurnOff) { * Remember to use bit notation and a bit operator. */ public static int turnOffAllSwitches(int switches) { - + return switches & 0b00000000; } /** @@ -47,7 +46,7 @@ public static int turnOffAllSwitches(int switches) { * I.E switches = 1 0 1 and switchesToFlip = 1 1 0 should return 0 1 1. */ public static int flipSwitches(int switches, int switchesToFlip) { - + return switches ^ switchesToFlip; } /** @@ -55,7 +54,7 @@ public static int flipSwitches(int switches, int switchesToFlip) { * NOTE: An integer has more than 8 bits, so find a way to only return the rightmost 8 bits. */ public static int flipAllSwitches(int switches) { - + return ~switches >>> 2; } /** @@ -64,14 +63,14 @@ public static int flipAllSwitches(int switches) { * So, a byte reads 76543210 */ public static int getSwitchPositionAt(int switches, int position) { - + return -1; } /** * Move all the the bits to the right `count` places. */ public static int moveRightBy(int switches, int count) { - + return switches >> count; } /** @@ -79,7 +78,7 @@ public static int moveRightBy(int switches, int count) { * NOTE: An integer has more than 8 bits, so find a way to only return the rightmost 8 bits. */ public static int moveLeftBy(int switches, int count){ - + return switches << count; } /** diff --git a/src/test/java/LightSwitcherTest.java b/src/test/java/LightSwitcherTest.java index 071bfd5..c047527 100644 --- a/src/test/java/LightSwitcherTest.java +++ b/src/test/java/LightSwitcherTest.java @@ -21,6 +21,7 @@ public void testTurnOnSwitches() { Assert.assertEquals(result2, expected2); Assert.assertEquals(result3, expected3); Assert.assertEquals(result4, expected4); + } @Test