BIT 115 – ASSIGNMENT 2

DUE DATE:  < Listed on the course schedule >

 

Part 1: Trace The Following Code

 

Trace the code for the following programs. When reading code that contains new types of robots with new services, “trace into” the code for the new service.  Also, don't forget to trace through all the city set-up code, including lines that create Things, and Walls.

 

You can find a sample program tracing table on the course website under the Blank Documents area, behind the link entitled Program Trace Table. 

 

Part 1.1:

Get A2_Trace_1.java from the website, and trace it.  You should name the file that contains your trace A2_Part_1_Program_1, and hand it in.

 

Part 1.2:

Get A2_Trace_2.java from the website, and trace it.  You should name the file that contains your trace A2_Part_1_ Program_2.

 

Part 2: Find Errors – Compiler, Logical, etc -

            Debug the program A2_Errors.java  Be sure the program not only compiles but performs appropriately according to the comments listed in the code. Again, record each error and its solution in a debug table. The source code is available on the website at A2_Errors.java.  You should put your answer to this part of the homework assignment in a file named A2_Part_2.

Line #

Error Description

Corrected line of code
(copy and paste from editor)

Type of Error

5

Missing semi-colon

karel.move();

Compile time error

 

Part 3: A Collecting Robot

 

You should put your answer to this part of the homework assignment in a file named A2_Part_3.java.  If you don't, you'll lose some points.  I would highly recommend downloading the file named A2_Part_3.java from the course website, and using that as a starting point for your work.

 

The program will begin as pictured in Figure 3.1.  You need to write code that will make the robot pick the Things up, and put the Things in the final row of the city, and end up with the city looking like it does in Figure 3.2.  HOWEVER, you want to design the robot so that it will work for any city that has the four horizontal 'pipes' (each containing a Thing), no matter how long those pipes are.  The program that you’re provided will randomly pick a width (within a reasonable range) so that you can  make sure that your program runs properly in a variety of circumstances.

Note that for this assignment you should create a new type of robot to accomplish this task, and you should do so by creating new, reusable commands.  The rubric has several commands listed that you should implement.

 

Figure 3.1: Two examples of how the city may look when the program starts

 

Figure 3.2: Two examples of how the city should look when the program ends


Group Work:

 

            For this assignment, you must complete the assignment INDIVIDUALLY.  There is to be no group work – all work must be your own, done by you, and understood completely by you.

 

Commenting:

 

            You will have to comment each service (each method) that you create – describe it's purpose, and include a brief description of the 'main idea' behind how it works.  If you were sitting down with a classmate, and had to explain the service in 30 seconds, what would you say?  You should focus on providing a conceptual view of what's going on. 

 

Additionally, put a comment next to any code that you found to be confusing, or that you think other people would find confusing. 

 

You need to spell your words correctly. You also need to write your explanation in your own words – no copying from other people.  You are encouraged to discuss with other people what your code does, to clarify your understanding, but the actual explanation should be your own.

 

The purpose of this requirement is to both help you understand, and have you demonstrate, a thorough understanding of exactly how your program works.

 

Every source file that you turn in should have, in a comment, your name (first and last), the name of this class (“BIT 115”), and the year and quarter, and the assignment number (“Assignment 2.0”).  If you’re handing this in again for a regrade, make sure to increase the minor version number by one (from “Assignment 2.0”, to “Assignment 2.1")

 

What to turn in:

 

 

How to electronically submit your homework:

 

Submit your homework via the StudentTracker tool, according to the same directions that were provided for the previous assignment.