Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

What is the Big Bang Theory?

Answered: 1 week ago