Logical Operators ( & Return Values )

Note:  Please keep the programs that you create today, in case you have a dispute about your grades for the ICEs at the end of the quarter. When you're working with a partner, each person should save their own, individual copy

 

Part  1: Creating Predicate Services Warmup

            Download the file  LogicalOperators.java, and write the code for the isNorthOfStreet10 command.  Make sure that the test code (in main) produces the correct results for your command.

            Then go on to write in the missing code for isSouthOfStreet5 command, and add some test code to main to make sure it works.

  

Part  2: Creating Predicate Services with Logical Operators (AND, OR, NOT)

(Skip this for now)

Outcomes: 2A, 2B, 2C, 3B, 3C

            Download the file ICE_14_Part_2_Test.java, and write the predicate service called isInRangeOfStreets(int low, int high) This tests whether a robot is between a given range of streets. The service should take two integer parameters, the lower number street and the higher number street and return true if the robot street is strictly between these two numbers. Otherwise the predicate service should return false.

            In that file, in main, there are a number of sample calls to this predicate service.  If you've written it correctly, you should see the following print-out when you run the program:

jo is between streets 0 and 2

jo is NOT between streets 1 and 2

jo is NOT between streets 4 and 10

Interactive Session Ended

 

Once you've done that, create a second, similar service to do the same thing for avenues

            isInRangeOfAvenues(int low, int high);

You should copy-and-paste the test code for isInRangeOfStreets, and modify it to test isInRangeOfAvenues.

 

Part  3: Creating Predicate Services with Logical Operators (NOT)

            Continue working with the file  LogicalOperators.java, and write the predicate service called isNOTInRangeOfStreets(int northMost, int southMost) This tests whether a robot is outside  given range of streets.  This method should work by calling isInRangeOfStreets, and using the NOT operator to reverse the answer it gets, and then to return that answer.

 

Part  4: Creating Predicate Services with Logical Operators (OR)

            Continue working with the file  LogicalOperators.java, and write the predicate service called isOutsideRangeOfStreets(int northMost, int southMost) This tests whether a robot is outside  given range of streets.  For this version of the method, you use use the logical operator OR to check and see if the robot is north of the northmost street, or south of the southmost street, and if so, return true.  Otherwise, return false