BIT 115: Assignment 2 Page 1/5 7/1/2016 BIT 115 – ASSIGNMENT 2 Due: Wednesday, July 27 Revision: Monday, August 8 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_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_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 Type of Error (copy and paste from editor) 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 BIT 115: Assignment 2 Page 1/5 7/1/2016 BIT 115: Assignment 2 Page 2/5 7/1/2016 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 BIT 115: Assignment 2 Page 2/5 7/1/2016 BIT 115: Assignment 2 Page 3/5 7/1/2016 Figure 3.2: Two examples of how the city should look when the program ends PLEASE NOTE: The Lecture 7 PowerPoint slide provides “hints” about successfully coding the A2_Part_3 java program (see slides 5 through 11) BIT 115: Assignment 2 Page 3/5 7/1/2016 BIT 115: Assignment 2 Page 4/5 7/1/2016 No 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 its 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 re-grade, make sure to either increase the minor version number by one or include the word ‘Revision’ (from “Assignment 2.0”, to “Assignment 2.1" or “Assignment 2 Revision”) What to Turn In A single electronic folder (a directory), whose name is your first and last names, and the homework number (2.0). This folder should contain: o All of the files used to solve the above problems. You will hand this folder electronically – there are directions, below. o All of the non-Java files need to be formatted like the Microsoft Word files that are provided on the website; not doing so will cause you to lose points. It's highly recommended that you use the MS Word files, but the instructor will also accept .PDF files as well (both Mac word-processing software and Open Office can export to .PDF) BIT 115: Assignment 2 Page 4/5 7/1/2016 BIT 115: Assignment 2 Page 5/5 7/1/2016 The following four (4) files must be submitted for Assignment 2: A2_Part_1_1. doc (or .docx) [Trace Table] A2_Part_1_2. doc (or .docx) [Trace Table] A2_Part_2. doc (or .docx) [Debug Table] A2_Part_3.java [Java Program File] For the A2_Part_3 java program, you only need to submit the .java file (please do not submit the .class file since I will be compiling the program myself during grading and will generate a new .class file). How to Electronically Submit Your Homework: Submit your homework via the Student Tracker tool under A2 in the select drop-down box, according to the same directions that were provided for the previous assignment. BIT 115: Assignment 2 Page 5/5 7/1/2016