Question: A Java question about bitwise operators. What need to do is, write down the correct value of north, south, west and east (instead of 0

A Java question about bitwise operators. What need to do is, write down the correct value of north, south, west and east (instead of 0 by default) in the block between start and end, based on the following code and a series of assertEquals.

A Java question about bitwise operators. What need to do is, write

Below is the code so that you can copy and paste:

@Test void should_do_flag_operations() { // TODO: // Please determine the values of each flag. //  int theNorth = north; int theSouthEast = south | east; int theNorthWest = north | west; int all = north | south | east | west; assertTrue(north != 0 && south != 0 && east != 0 && west != 0); assertTrue(north != south && north != east && north != west && south != east && south != west && east != west); assertEquals(north, north & theNorth); assertEquals(north, north & theNorthWest); assertEquals(north, north & all); assertEquals(south, south & all); assertEquals(east, east & all); assertEquals(west, west & all); assertEquals(theNorthWest, theNorthWest & all); assertEquals(0, north & theSouthEast); assertEquals(0, north & south); assertEquals(0, north & east); assertEquals(0, north & west); }

@Test void should_do_flag_operations() { // TODO: // Please determine the values of each flag. // int the North = north; int the SouthEast = south east; int the North West = north west; int all = north south east | west; assertTrue( condition: north != 0 && south != 0 && east != 0 && west != 0); assertTrue( condition: north != south && north != east && north != west && south != east && south != west && east != west); assertEquals(north, actual: north & the North); assertEquals(north, actual: north & the Northwest); assertEquals(north, actual: north & all); assertEquals(south, actual: south & all); assertEquals(east, actual: east & all); assertEquals(west, actual: west & all); assertEquals(theNorthWest, actual: theNorthWest & all); assertEquals( expected: 0, actual: north & the SouthEast); assertEquals( expected: 0, actual: north & South); assertEquals( expected: 0, actual: north & east); assertEquals( expected: 0, actual: north & west); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!