bit 115 – spring 2001 - programajama! web viewbit 115 – assignment 1. due: ... clockwise...

9
BIT 115: Assignment 1 Page 1/9 3/3/2022 BIT 115 – ASSIGNMENT 1 Due: Section 1: Monday, January 22 Revision: Section 1: Wednesday, February 7 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 the 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. BIT 115: Assignment 1 Page 1/9 3/3/2022

Upload: tranthu

Post on 07-Feb-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

BIT 115: Assignment 1 Page 1/7 5/5/2023

BIT 115 – ASSIGNMENT 1

Due: Section 1: Monday, January 22Revision: Section 1: Wednesday, February 7

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

BIT 115: Assignment 1 Page 1/7 5/5/2023

BIT 115: Assignment 1 Page 2/7 5/5/2023

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 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 or .rtf or .pdf. 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

BIT 115: Assignment 1 Page 2/7 5/5/2023

BIT 115: Assignment 1 Page 3/7 5/5/2023

Figure 3

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 or .rtf or .pdf.

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.

BIT 115: Assignment 1 Page 3/7 5/5/2023

BIT 115: Assignment 1 Page 4/7 5/5/2023

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 or .rtf or .pdf.

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/run-time 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).

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.

BIT 115: Assignment 1 Page 4/7 5/5/2023

BIT 115: Assignment 1 Page 5/7 5/5/2023

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 5/7 5/5/2023

BIT 115: Assignment 1 Page 6/7 5/5/2023

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 java 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”), Section number (“Section 1”) the quarter and year (“Winter 2018”), and the assignment number (“Assignment 1”). 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:

BIT 115: Assignment 1 Page 6/7 5/5/2023

BIT 115: Assignment 1 Page 7/7 5/5/2023

// Rex Winkus// BIT115 Assignment 1 (Section 1)// Winter Quarter 2018 (Instructor: Craig Duckett)import becker.robots.*;

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 zip folder should contain two (2) .java files and three (3) document files: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. NOTE TO MAC USERS: Please do not submit .pages file if you are a Mac user, because I am unable to open these in Windows. Instead, save your file as a .pdf file and submit that so I can open and grade them properly. Thanks!

Questions or Confusion? Contact Me!

Do not hesitate to email me at [email protected] 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.

BIT 115: Assignment 1 Page 7/7 5/5/2023