BIT 115: Assignment 1 Page 1/6 7/1/2016 BIT 115 – ASSIGNMENT 1 Due: Monday, July 18 Revision: Monday, August 1 Part 1: Writing Code: Robot Pipe-Cleaning Much in the same way it's important for you to exercise your coding skills, the engineers designing the robot also 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 its 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 BIT 115: Assignment 1 Figure 2: Ends Up Looking Like This Page 1/6 7/1/2016 BIT 115: Assignment 1 Page 2/6 7/1/2016 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 two sentences, tops). Note that you must leave the program in exactly the state pictured above—the robot even has to be facing the correct north 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 Program Debug Table like so (available for download on the main page of the BIT115 website under the section labeled TEMPLATES USED IN CLASS). 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.doc or docx. You do not need to turn in the corrected .java file, only the table file listing all the errors, the corrections, and types of errors (e.g., logic, compile time error). Initial State Final State Figure 3 BIT 115: Assignment 1 Page 2/6 7/1/2016 BIT 115: Assignment 1 Page 3/6 7/1/2016 Part 3: Code Tracing (Easy) For this portion of the assignment, you should use a Program Trace Table, available for download on the main page of the BIT115 website under the section labeled TEMPLATES USED IN CLASS. 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.doc or docx. 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) For this portion of the assignment, you should use a Program Trace Table, available for download on the main page of the BIT115 website under the section labeled TEMPLATES USED IN CLASS. 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.doc or docx. If you find any errors in the provided file, you will 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/runtime error. In the trace table, if/where it crashes, just write out ROBOT CRASHES HERE BECAUSE … 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). BIT 115: Assignment 1 Page 3/6 7/1/2016 BIT 115: Assignment 1 Page 4/6 7/1/2016 Part 5: Clockwise Around the box Given the Starting_Template.java file (available for download 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 (and this means you will need to rename the Class to A1_Part_5 or the program will not compile). When doing this you must look for opportunities to create useful new methods, 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. BIT 115: Assignment 1 Page 4/6 7/1/2016 BIT 115: Assignment 1 Page 5/6 7/1/2016 This is an Individual Assignment, so No Group or Team Work: For this assignment, you must complete the assignment INDIVIDUALLY. There is to be no group work on Assignment 1 – 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 do this correctly, jGrasp will color the entire line orange by default (if you prefer you can change the orange to another color in jGrasp under Settings > Colors): // This is some text, and usually explains something that may need additional info 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 until it hits the Finish Line – woot! woot! 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: // Rex Winkus // BIT115 Section 1 or 2 - Assignment 1 // 2014 Fall Quarter (Instructor: Craig Duckett) import becker.robots.*; BIT 115: Assignment 1 Page 5/6 7/1/2016 BIT 115: Assignment 1 Page 6/6 7/1/2016 What to Turn In: A single electronic folder (a directory) zipped, whose name is your first and last name, and the homework number (1.0). Example: RexWinkus1.zip This folder should contain: o All of the files used to solve the above problems: A1_Part_1.java A1_Part_4.doc A1_Part_2.doc A1_Part_5.java A1_Part_3.doc Personal Data Sheet (Optional) o Make sure and submit .java files and not .class files (I don’t need the .class files, but I do need the .java files in order to grade your assignments) o You will hand this zipped folder file in electronically—we will cover this in-class on the day the assignment is due. 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 (either .doc or .docx), but the instructor will also accept .PDF files (both Mac word-processing software and Open Office can export to .PDF) or .RTF formatted documents. Questions or Confusion? Contact Me! Do not hesitate to email me at cduckett@cascadia.edu if you have any questions or need clarification regarding any portion of your assignments. You are also invited to come see me any time during my scheduled offices hours for some personal sit-down face time and/or instruction. I want all of you of you to be successful in learning how to program, so don’t hesitate to ask for help if you find yourself confused or getting lost in the logic of the code. My office is located on the second floor in the small alcove in the doorway just to the right of the elevator (in CC1-203). My office hours adjusted for Summer Quarter 2015 are Mondays and Wednesdays from 10:30am-11:30am (give or take). BIT 115: Assignment 1 Page 6/6 7/1/2016