Ice01 New Robot Commands (Methods)

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

 

ICE ICE 3.1: Code Tracing

Download the following file from the course website, and trace through it:

ICE_03_01_Trace.java (This is a bit more complex, but you should be able to trace it just fine using the Program Trace Table)

If you get done with the above exercise, then go on to ICE 3.2. If you haven't yet heard the explanation for the syntax, then give it your best shot, and see what you can figure out on your own.

When you get done with this exercise, go on to the next section. Go Next


ICE ICE 3.2: Finding Errors

When you try using any new feature of a computer programming language, you'll end up making many mistakes. Some will be conceptual, and some will be purely not knowing what to type.

For this part of the In Class Exercises, you'll download a file from the website ICE_03_02_CompileErrors.java, and work with a partner to find all the errors that you can.

In order to get this done, you're welcome to refer to any books, handouts, or any other person if it'll help you find what's wrong. However, by the time you get to ICE 3.3, you should know and understand any of these errors, so that if you make them on your own, you can fix them on your own.

Further, once you've found five or more errors in the source code, you should raise your hand, so the instructor can check one or more. You should record each bug in following format using a Program Debug Table:

Line #

What's the Problem?

Text Before/After You Fixed It

Type Of Error

13

Missing semi-colon: the Java language requires that each command ends in a semi-colon, and so the program won't compile without it.  I fixed the problem by adding a semi-colon

Before: this.turnLeft()

After: this.turnLeft();

Syntax / Compile-Time Error

Etc Etc Etc Etc

When you get done with this exercise, show your Instructor, then go on to the next section. Go Next


ICE ICE 3.3: Write Code, Walk Down a Wall

Use the city set-up given in ICE_03_03_WalkDownWalls.java as a starting point.

Create a new type of robot that knows how to walk down a wall three spaces tall (create and code a new method called walkDownWall.) The new service should leave the robot facing in the same direction as when it started.

Recall that you can add more than one service to a new type of robot so feel free to also include (and use) the turnRight service that was described earlier. This can make your code more readable, but is not required. The initial and final state of the program is shown in below.

Initial State Final State - Success!
Start Finish

Flowchart