ITK 168
Spring 2008

Lab 1 Instructions

Welcome to your first 168 lab session!

Completion of the lab exercises is very important in this course, because labs give you an opportunity to make sure you understand the course material, and they give you a chance to practice new skills before using them to write your larger lecture programs. Therefore, you should take your lab work very seriously.

Note:

This set of instructions assumes that you are familiar with the Windows operating systems and can copy files, run programs, etc. If that is not the case, please get individual help from your lab instructor.

Preparing for lab

In most cases, there will be one or more pre-lab exercises: work that you are expected to complete before coming to lab. At the beginning of each lab, your GA will look at your pre-lab to be sure it is completed (it does not have to be correct, but a reasonable attempt is required for points). Be sure to check the course website for the pre-lab assignment well before your lab date so that you can complete the pre-lab work.

Your 168 log-in

Your lab instructor will provide you with a log-in id and a password for an H drive account you should use for 168 work only. Please do not change your password, and do not share it with anyone. Please do not login using your ULID as that will not give you access to your department H drive.

The H drive account will provide you with an a portion of a networked hard disk that you can access from virtually any computer on which you can access ADILSTU – including the lab and your dorm room or apartment. The purpose of this is to give you a place to store your course work. You must not store anything else on this disk (particularly not multi-media files of any kind).

The account also gives you access to the department’s T drive. This contains information provided by instructors for various ITK courses. Any files that we provide you for lab will be made available on the T drive. You can copy things from the T drive, but you may not modify anything on the drive.

Do this:

Log on to the computer using your 168 id and password. Locate the T drive. On the T drive, look in the folder itk168\Labs. You’ll find folders there for each week of lab. Copy the Lab01 folder to your H drive.

Submitting your work

At the end of this document, you’ll find instructions for electronically submitting your work. This is on its own sheet so that you can keep it handy throughout the semester. Make sure that you correctly submit all lab assignments. Lab assignments should be submitted to your lab section (2, 3, 5, 6, 8, 9, 11, or 12) not your lecture section (1, 4, 7, or 10).

Do this:

Using Notepad or any other appropriate software, write a short note to your lab instructor and save it as a .txt file named memo.txt. In your note, include the following information: Your name, your ULID, your lab section, your lab instructor’s name and answers to the following questions:

1)What computer applications have you used enough to be comfortable with (including word processors, games, etc)?

2)Do you have any programming experience? If so, what have you done?

3)Do you have a computer?

After completing this lab, submit your completed memo.txt file to your lab section following the Web Submit instructions at the end of this document.

Working with programs in Eclipse

Follow the instructions below. Refer to this section of the lab when you need to load, compile, or execute a program in later activities. Note: Some screen shots may appear different on your computer. If you get confused, ask your lab instructor forhelp.

1.Creating a project in Eclipse

At the top of your desktop, there is a folder named Java tools. Open that folder, and double-click on the program labeled Eclipse 3.3 work – H Drive

From the File menu, select New and then Project….

In the pop-up window that appears, make sure Java Project is selected (you may need to expand the Java folder to locate the Java Project link), and click on the Next > button.

Type the name Lab1 into the Project Name textbox and click on the Finish button.

2.Setting up a Robots project

This part of the instructions applies ONLY to projects that use the Robots library supplied by your textbook author. The Robots library is a set of Java classes that provide a bunch of capabilities for robots and their worlds. In order to use the classes, you have to add the library to your project.

First, copy the becker.jar file from the D: drive to your H: drive. To do this, go to windows explorer and open the folder D:java/jars. Copy the file becker.jar (take care to get the correct file) and paste a copy on your H: drive (do this in the root directory, not within any folders). Next, build a path to the becker.jar within your Lab1 project. Return to Eclipse. In the Package Explorer panel on the left side of the window, right-click on the project folder for Lab1; from the pop-up menu, select Build Path  Add External Archives; find the becker.jar file on your H drive and select it. Using a copy of becker.jar from your H: drive rather than the D: drive will prevent problems when working from home.

Now you have access to all the Becker classes. Remember, you must do this each time you create a project that uses the robot library. Otherwise, you will see a bunch of errors that can be very confusing.

3.Importing a Java file into a project

Now we want to load a Java file into our project in Eclipse. You’ll follow this procedure any time you are provided with a file that is to be part of your project. The file we’re going to import into Eclipse is called GoAroundRoadBlock.java. It should be on your H: drive, inside the Lab01 folder that you copied earlier.

In your Eclipse window, expand the Lab1 folder in the Package Explorer and select the .src folder. Then go to the File menu and choose Import…

In the resulting dialog box, select File System(you may need to expand the Generaltab to locate the link) and then click on the Next button

In next dialog box, you’ll use the Browse button next to the From directory textbox to locate the folder in which the file is located. It’s very important that you’re looking for the folder the file is in, not the file itself. Although it’s confusing at first, this is actually a nice feature, because it allows you to import several Java files that are located in the same folder into a particular project.Remember that you’re looking for the Lab01 folder on your H: drive. Once you’ve selected that folder, click the OK button.

Select GoAroundRoadBlock.java (select it by clicking in the box to the left of the file name), and make sure that the folder you are importing into is Lab1/src.

Then click on the Finish button. The import process may take a little time. Once it has completed, click on the plus (+) sign next to Lab1, the one next to src, and then the one next to (default package) – you may need to close the Welcome window. You will see that GoAroundRoadBlock.java has been imported into the project. Double-click on GoAroundRoadBlock.java, and the code will appear in one of the panels in the Eclipse window.

This is one of the example programs from chapter 1 of your textbook. Look at it closely. The first few lines set up the city, the walls, and the robots. The remainder move the robots around in the city.

4.Running a Java program in Eclipse

Computer programs aren’t very interesting until we make them actually run. To run a Java program in Eclipse, select the file you want to run a program from (in this case, GoAroundRoadBlock.java), and then go to the Run menu and select Run as and Java Application.

Alternatively, you can right-click on the file, and then select Run As and Java Application from the resulting pop-up menu.Note: If Java Application is no a choice in the Run As menu, you have not selected the correct file to run. Only files with a main method can be run as a Java Application.

On your gradesheet, briefly describe what this program does (to show your lab instructor that you have successfully run the program).

5.Modifying a Java Program

The final task you’ll complete in this lab is to make a modification to a Java program. Look closely at the portion of the program that makes the robots move around. Modify that code so that the robots meet one block further south and on the east side of the roadblock (rather than west). Follow the directions above to run your program and make sure it works.

Hints: After making changes to code, you must recompile the code. In order to do this, click the Save button. If Eclipse finds errors in your code, it will list the errors in the box at the bottom labeled Problems. Double clicking on a problem will cause the editor window to show you the line of code the problem is referring to. You will also see little symbols appear to the left of lines of code that have problems as you type. If the symbol includes a light bulb, you can right-click on the light bulb to get suggestions about ways to fix the error.

Once your modified program is working correctly, follow the Web Submit instructions to submit the modified .java file to your lab section. Make certain that you submit the correct file. It will be located in a folder named “Work” on your H drive, inside the Lab1 folder. Don’t accidentally submit the original file that you copied from the T drive.

6.Submitting Your Work

Follow the submit instructions on the final page of this document. Name your file Lab1.zip

Make sure to submit both your memo.txt and the modified GoAroundRoadBlock.java. You are to submit a single zip folder with these 2 files. It will be easier if you move your memo.txt file into the H:\work\Lab1\src folder so you can easily select both files to zip.

Web Submit – Labs and Programs

Step 1: First you need to prepare your files for submission. When you use web-submit your ULID is added to the front of the file name to distinguish your submit from others. Java file names must match the name given to the class definition. If the file name is changed, the class will not function. To avoid this, you will be required to zip all your submitted files into a single zip folder. You are to zip individual files only. DO NOT move your lab files into a folder as this will make grading more difficult and your grade will be reduced for it.

Follow these steps to zip your lab files:

  • Typically you will be submitting multiple files for each lab. Please submit only one file so you must wait until your entire lab is complete to submit.
  • Locate all files to be submitted. Remember that you are to submit the .java file NOT the .class file for all Java classes. Submitting the .class file instead of the .java file will reduce your grade.
  • Use Ctrl-click to select all files to be submitted.
  • Right click on the set of selected files and choose Send To -> Compressed (zipped) Folder
  • Take care in the naming of this folder. Each lab will dictate the name to use. Failure to use this name will also reduce your grade.

Step 2: Open the Web Submit screen:

  • From a lab computer – double-click on the Web Submit icon on the desktop.
  • From any browser –

Step 3. First screen: Click on Submit Your Files, then enter the logon information using the following:

Select your class from the menu. Then select your section number. Be certain you chose the correct section. If you submit to the wrong section, your instructor will not be able to access your file and will assume you did not submit it. Use your lab section in lab and your lecture section for programs for class.

Step 3. Be certain that your instructor’s name appears on the second screen. Enter your ULID, select the correct project #, and browse to locate the file you are submitting. For labs, the project number makes the lab number: Lab 1 = Project 1, Lab 2 = Project 2, etc. It is important to submit to the correct project folder! Click submit. If you find you have made a mistake, chose reset and start over.

If you submit the wrong file,submit to the wrong section or wrong project number, or you decide to change something in your work, simply resubmit the correct file. Files with the same name will be overwritten so only the latest submission will be found during the grading process. You have a full week to submit lab work, but it must be submitted prior to your next lab date. Do not resubmit after the due date or you may not receive credit.

Step 4. Each time you submit you will receive an e-mail confirming that your file was received. Save this e-mail until you receive a grade on that assignment. IMPORTANT: If you do not receive a confirmation e-mail but you did submit a file, contact your instructor immediately.

Name ______Lab 1 Participation ______(15)

ULID ______Lab 1 Activities ______(15)

Section ______Lab 2 Pre-lab/Participation ______(15)

Lab 1 Grade Sheet

Lab 1 Activities (15 points)

______(5) Notepad memo submitted to your lab section

______(5) Description of the behavior of the original GoAroundRoadBlock.java program

.

______(5) Modified GoAroundRoadBlock.java submitted to your lab section

Lab 2 Pre-Lab and Participation (15 points)

______(5)Pre-Lab

______(10)Participation