Individual assignment for Tue 9/29: ---------------------------------- You may complete this assignment in the lab or at home. If you're going to work at home, complete step (0). (0) Install the JDK (Java Development Kit) and BlueJ on your computer. Instructions are at: http://www.mathcs.emory.edu/~cs190000/resources.html#Java (Steps 2. and 3.) (1) Read over the exercise packet at: http://www.mathcs.emory.edu/~cs190000/share/tutorials/JLAB01.pdf Although you won't be turning this in, your are responsible for the material in this packet. I encourage you to try the exercises are you are reading along. I am likely to quiz you on it. (2) Complete the exercise packet at: http://www.mathcs.emory.edu/~cs190000/share/tutorials/JLAB02.pdf Complete and turn in post-lab problem 2.2. You do not have to turn in the experiments you complete, although you are required to do them, and I will assume you have done them when formulating a quiz. ---------------------------------- -We demonstrated lejos on an actual NXT -We fixed the Forward program from last time -We found that it simply quit when run -As with NXT-G, the program is quitting before we are able to see any movement -Fix 1: we added an infinite loop at the end of our program while (true) { // empty body } Empty loop bodies may be omitted in Java, the following is equivalent: while (true); Note that "true" in Java is a boolean constant, just like "1" or "456" are int (integer) constants. -Fix 2: Use the bump sensor. For this we referred to our lab manual (Section 2.5). We saw that unlike using motors, we need to lay some foundation before we may interact with the bump sensor: TouchSensor myBumper; // create a new variable of type TouchSensor named myBumper myBumper = new TouchSensor(SensorPort.S1); // create a new TouchSensor object and // assign it to myBumper Now we can test the bumper by the following method call: myBumper.isPressed(), which returs either true or false (boolean) So our loop becomes: while (myBumper.isPressed() == false); // loop while isPressed() returns false -We also discussed comments, demoed the lejos compilation process, and talked more about method, parameters, and return types Files: Foward.java