This first assignment is a collection of exercises designed to use the programming ideas and tools we have learned to date.
There will be a number of files to turn in, so please check to ensure you have completed each one.
- Trace-table document, labeled A1_trace.doc
- Debug table document, plus fixed code, labeled A2_Errors.doc and A2_Errors.java
- Clockwise box robot code, labeled BoxBot.java
- Collecting robot code, labeled CollectingBot.java
Grading, for the trace-table and debugging exercise will be based on completeness of the exercise.
Grading for the two coding
exercises will be based on completion of the exercise, which includes creating the requested additional commands. There will also
be some points awarded for organization of code, style of code (correctly indenting, and bracketing), and commenting of code.
Comments should describe the purpose of each service / method / function that you create, as well as your approach to solving the
logic of putting those services together.
You should use the program source code tracing handout, located on the website, under the Blank Documents area, behind the link
labeled Program Trace Table, to trace through the program for this part.
The program that you'll trace for this part of the assignment
is available on the website, in the file A1_trace.java.
You should save your trace for this program in a
file named A1_trace.
If you find any errors in the provided file, you should fix any compile-time errors in a reasonable manner, and then trace the file anyway.
For any run-time (or logical/intent) errors, you should trace up to the statement which causes the robot (or program, etc) to crash,
and explain why that statement causes the robot to crash, but do not trace beyond the logical/run-time error.
Note: that it's perfectly legal to have avenue and streets that have negative numbers (i.e., the avenue immediately to the west of
avenue of 0 (zero) is avenue number -1).
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. You should put your answer to this part of the homework assignment
in a file named A2_Errors.
- Go around the Box
Given the Starting_Template.java file, you need to write the code to create the city
(as pictured below),
and then write the code to move the robot clockwise around the box.
You need to name the file that contains your solution BoxBot.java.
The robot must start the program as pictured below, go around the box clockwise, and then end the program in the same intersection that
it started in (as pictured below).
When doing this you must look for opportunities to create useful new commands (services / methods/ functions), and you must then use them.
One example might be a
"turnRight" command. You should implement at least two new commands.
- Collect the Things
You should download the code called CollectingBot.java. This program will begin as pictured below.
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 below.
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.