Archive for the ‘AP Computer Science A’ Category

Tired of crabs, lizards, and actor masks?

The procedure to change the icon used in a Gridworld project is as follows:

Create the desired graphic as a 48×48 pixel GIF image.

Save the image in the same folder as the .class file for the bug or critter or actor.

For example, if you create a class called testcritter that extends critter using Eclipse and assuming the default location for the workspace, place the graphic in the bin folder located in …/project/workspace.

On a Windows 7 system the file location for a user named Bob would be:

c:\users\bob\workspace\testcritter\bin

Java Bitwise Or

Posted: January 11, 2010 in AP Computer Science A
Tags: , , , , ,

Java Bitwise Or

System.out.print(15|32) returns 47

which is tricky because you assume that addition is taking place. But the following line

System.out.print(11|33) returns 43

This is not addition, it is called the bitwise Or. To illustrate:

Step 1: Convert the integers to binary lining up the digits in place value.

11 = 001011
33 = 100001

Step 2: Or the digits in corresponding place values (right to left or left to right doesn’t matter in the case of Or)

0 0 1 0 1 1
OR 1 0 0 0 0 1
Result 1 0 1 0 1 1

When using an Or, if both digits are 0 the result is 0. All other cases result in 1.

Step 3: Convert to decimal if necessary.

101011 = 43

1 – download and extract JAR file to a local folder
2 – In NetBeans, select Tools – Libraries
3 – Click Add JAR/Folder and point to the location of the JAR file