Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started