BIT 115 – ASSIGNMENT 1

Due Date: < Listed on the course schedule >

 

Part 1: Writing Code : Robot Pipe-Cleaning

 

Much in the same way that it's important for you to exercise your coding skills, the engineers designing the robot need to exercise the robot.  You'll be making sure that you can remember how to give the robot commands, how Java programs work, and how to make jGRASP do what you want it to.  For the robot, your commands will make sure that it's able to do what it's supposed to, without having any syntactic problems, logical problems, etc. 

On the website, there's a link to a file named A1_Part_1.java, which contains source code to create a city that looks like the one pictured below, in Figure 1.  You can imagine that this is a picture of a pipe, from the side (in a 'cut-away' sort of picture). You need to write code that will move the robot from it's starting point to the two Things, picking Things up and dropping them off so that when your program finishes, the screen will look like Figure 2, below.

 

Figure 1: Starts Out Looking Like This

Figure 2: Ends Up Looking Like This

 

 

Your solution to this part of the assignment must be contained in a file named A1_Part_1.java.  If you find any errors in the provided file, you should fix it in a reasonable manner, and write comment explaining your fix, and why it's reasonable (this should be 2 sentences, tops).  Note that you must leave the program in exactly the state pictured above – the robot even has to be facing the correct direction.

 

 


Part 2: What's Wrong With This Code?

 

Download the A1_Part_2.java program source code from the website.  The program is supposed to make Jo The Robot perform diving acrobatics (see Figure 3) – but it’s not yet working. Find, document, and correct all the errors in the code in order to get Jo into the pool.  Your program needs to look identical to the Initial State picture below and on the left, must then follow the red line drawn on the Initial State picture, and must finish looking identical to the picture on the right (Final State).

 

Provide documentation of the errors in the form of a table like so.

Line #

Error Description

Corrected line of code
(copy and paste from editor)

Type of Error

5

Missing semi-colon

karel.move();

Compile time error

 

            You should put your answer to this part of the homework assignment in a file named A1_Part_2.

 

Initial State

Final State

Figure 3

 

 


Part 3: Code Tracing (Easy)

 

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_Part_3.java.  You should save your trace for this program in a file named A1_Part_3.

 

If you find any errors in the provided file, you fix any compile-time errors in a reasonable manner, and then trace the file anyways.  For any logical / run-time 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.

 

          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).

 

 


Part 4: Code Tracing (More Interesting)

 

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_Part_4.java.  You should save your trace for this program in a file named A1_Part_4.

 

If you find any errors in the provided file, you fix any compile-time errors in a reasonable manner, and then trace the file anyways.  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).

 

 

Part 5: Clockwise around the box

 

Given the Starting_Template.java file(available on the website), you write the code to create the city (as pictured in Figure 4, below), and then write the code to move the robot clockwise around the box.  You need to name the file that contains your solution A1_Part_5.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 stated in (as pictured below).

Amendment (from lecture on 7/7): When doing this you must look for opportunities to create useful new commands, and you must then use them.  One example might be a ‘turnRight’ command, but you should look for others, too.

 

Figure 4

 

 

Part 6: Personal Data Sheet

 

Download the personal data sheet from the website, and fill it in.  You’re not required to do this, and you should only fill in those parts that you want to (and feel comfortable filling in).  It will help your instructor get a better understanding of who’s in the class, and why you’re taking the class. 

To be clear: There is NO point penalty for leaving this part out, or for leaving any part of the Personal Data Sheet blank.

 

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:

 

A comment is a line that contains English text, instead of Java source code.  In order to tell Java to ignore the line (so that you can put the English text in), you need to do one of a couple things.  For now, you'll simply put two forward slashes at the beginning of the line, right next to each other, before anything else.  If you this correctly, SitePad will color the entire line green, like so:

 

// This is some English, and usually explains something that's confusing.

 

Put a comment next to any code that you found to be confusing, or that you think other people would find confusing. The purpose of this requirement is to both help you understand, and have you demonstrate, a thorough understanding of exactly how your program works.

 

            Further, you should put a comment next to each conceptual block of code.  What is a 'conceptual block of code'?  It's a bunch of lines that are all right next to each other, and do something interesting.  It is a bit of a personal judgment call – what one person may think of as being a conceptual block another person might think is three, while yet another person thinks the so-called block is really just half of a larger block.  Part of your job as someone learning how to program is figuring out what's useful enough to compose a 'conceptual block'. 

 

            You should put a comment next to each conceptual block.  For example, if you were writing a program to run the robot around a racetrack, you might have a comment like:

 

// The robot is facing east, and about to move across the southern wall of

// the racetrack

 

before the sequence of move(); commands that move the robot across the southern wall. 

 

Every source file that you turn in should have, in a comment at the very top of the file, your name (first and last), the name of this class (“BIT 115”), the year and quarter, and the assignment number (“Assignment 1.0”).  If you’re handing this in again for a regrade, make sure to note that (e.g. instead of “Assignment 1”,  list it as “Assignment 1 Revision").  Example:

 

// Assignment 1.0, by Mike Panitz

// 2012 Fall quarter, for BIT 115 (Instructor: Mike Panitz)
            // Section: <whatever section you're in>

            import becker.robots.*;

 

 

 

 

What to turn in:

 

A1_Part_1.java

A1_Part_4.doc

A1_Part_2.doc

A1_Part_5.java

A1_Part_3.doc