CSE 113 - Spring 2009 - Banner
UB -
University at Buffalo, The State University of New York Computer Science and Engineering
  • CSE 113 - Spring 2009
CSE 113 - Spring 2009 - Navigation
CSE 113 - Spring 2009 - Announcements

Lab 1

CSE 113 - Spring 2009 - Announcements

Week 1 (1/19-1/23)

Login

Make sure you can log onto the computers in Bell 340. After you log in, make sure you know how to log out. Make sure that you do not leave your computer logged in while you are not using it.

If you have a problem logging in, make sure to talk to the TA in your recitation section so that they can make note of your UBIT name and ensure that your account is working for next week.

If you can log in, continue on to the following. After you have completed the next section, you are free to leave and continue the rest of the assignment next week in recitation.

Run Setup Script

You need to run a setup script in order to more easily work on the labs this semester. After you log in, type:

~alphonce/cse113init

at the prompt. This will set up your account so that all you need to do is type drjava at the prompt and the DrJava program will open up for you.


Week 2 & 3 (1/26 - 2/6)

Unix Commands

The operating system you are using in the Bell 340 and Bell 101 labs is a form of Unix. Each version of Unix can have it's own look and feel. Therefore, the icons and menus that you see may or may not be there if you log into the system in another lab enviornment or even another machine in the lab.

What does remain constant is the ability to do certain things from the terminal's prompt. There are several common operations that you should be familiar with while you are continuing your work on this and future assignments. Do not be concerned with memorizing these operations, but rather feel comfortable in returning to this as a guide while you are working on the Unix systems.

Read through this section now and complete the "exercises" that you are instructed to so that you can see how to work with the systems.

  • ls - This command gives a listing of the files in a directory. Without any arguments, it provides a listing of the files in the current directory, and is therefore equivalent to

    ls .

    If you specify a directory using a path, ls will respond with a listing of the contents of the specified directory. Try typing ls at the Unix prompt to see if you have any files in your directory. If this is a brand new account, you may not have any, but if you do, they were put there to help make your account function properly. Never delete any files that you did not create.

  • cd - This command changes the current directory. Without any arguments, it changes the current directory to your home directory, and is therefore equivalent to

    cd ~

    If you specify a directory using a path, cd will set the current directory to the specified directory. One neat thing is that using .. as an argument to cd moves you to the parent directory.

  • man - The man command brings up a manual page (help screen) for a specified command. Let's get the man page for the finger command by typing man finger.

  • mkdir - This command creates the specified subdirectory. Create a directory called temp by typing

  • mdkir temp

    Now, if you type ls at the prompt, you will see a directory named temp in your account.

  • cp - This command copies a file to a new location, leaving the original unchanged.

  • mv - This command moves a file from one location to another. But beware, because of the way file systems work, moving a file is very similar to renaming. The mv command is also the rename command. A directory is just a special type of file to Unix, so we can rename the directory we just created before by moving it to a new location. For example we can rename the directory called temp by:

    mv temp cse113
  • rm - The command rm removes a file. It is adviseable to always use the rm command with the -i flag so that you are prompted to decide if you really want to remove something. For example, typing rm -i cse113 would prompt you to make sure you really wanted to remove. If you didn't want to, you can simply answer n to the prompt. You shouldn't really have to worry about deleting much this semester, but it is important to know that you can do it.

  • rmdir - This command removes the specified subdirectory.

These operations are not unique to commands at the prompt. Most of the windowing systems and variations of Unix have some sort of file manager-like program that would allow you to do these things without typing commands. If you want to explore that functionality, you are free to do so. Simply make sure you know how to do the same things described above.

You should know how to open the web browser so that you can refer to information on the course website while you work on this and future labs. From the prompt, you can type the name of the browser you want to use like netscape or firefox.

For now, you should make sure you have a directory named cse113. Inside the cse113 directory, you should create directories for labs 1 through 4 so that you don't have to do this for each assignment. This way, you can save your work from each lab into its own place.

Start DrJava Environment

At the prompt, type drjava

This will open the Dr Java environment like was shown in class.

You will need to do one piece of setup before beginning the exercises. Once this is done, it will not need to be repeated (unless you move to a different computer - like your own, but see instructions for that below).

Click on the Edit menu and then on the Preferences Menu item. A dialog box will appear. It will look like this (except all fields will be blank):

Preferences Dialog

You will want your dialog to have a directory in the Extra Classpath text area when you close the dialog. The directory you will want to see is /eng/class/notes/cse113/intro-prog-java/bookClasses

In order to do this, click the Add button and navigate up into the directory that is two above your home directory. There you will find the class directory, navigate into that and then into notes and so on. You need to make sure to click until you have the directory bookClasses in the path. When you are done with navigating the proper place, you should see a line similar to the one in the picture above. Click OK to close the preferences dialog.

You should proceed to the interactions pane to perform the next set of exercises. All of the following should be done in the interactions pane. For submission, you will save the contents of your interactions pane into a file named lab1.hist. Since some of these things will take some time to work through to make them look correct, it might make sense to work through the details of these in a "scratch run" meaning that you will write down the things you are doing (in a notebook perhaps), but will not use the session as the final submission. When you have figured out what code to write, you can close DrJava and open it again starting a fresh interactions pane and only type the exact lines you need to complete the assignment. This might make the process easier for some people. Others will like to tinker with the assignment until it is finished in one long session, which is fine as well. Either way, you need to submit the lines of code that complete the assignment in one file. Which also means that if you do half the assignment in one session and half in another, you will need to repeat the first half before starting the second so that all of the assignment appears in one file.

Creating Worlds and Turtles [Quick Reference for Turtle methods]

[STEP 1] Create a variable for a world and create a new instance of a world and assign it to that variable. You can name the world variable whatever you would like.

[STEP 2] Create two variables for turtles. Call one of the variables turtle1 and the other turtle2. Create Turtle objects for each of these variables and assign the variables accordingly.

[STEP 3] Put each of the turtles into the world you created in step1.

[STEP 4] Move turtle1 to the position (50,50) on the screen, making sure to put its pen up before moving so that there is not a line drawn. Starting from that point, create a 100 x 100 square that extends to the right and down from the point (50, 50). Essentially, the square should be entirely visible on the screen.

[STEP 5] Move turtle2 to the position (50, 250) on the screen, once again making sure its pen is up before moving. Make turtle2 face turtle1 and then have turtle2 draw a square of size 100 x 100 from that point. If this square goes off the screen, that is fine.

[STEP 6] Move turtle1 to the position (300, 100) on the screen, once again making sure that the pen is up before moving. From this point, assume a 300 x 200 box available to you in which to make turtle1 draw your initials. The initials do not have to take up the entire space, but should be relatively large and should not exceed the space. You can draw your first and last initial, or if you have a middle name, all three initials. The first initial you draw should be drawn in the color red and the second initial should be drawn in the color blue. If you draw a third initial, you can pick any color you would like for the initial. Here are my initials as drawn by the turtle.

Initials

Saving a copy of the code you wrote

When you are finished with the 6 steps needed to complete this assignment, you should save your interactions history to a file. Right click in the interactions pane and select Save Interactions History. A dialog will appear where you can select a location to save it to. Navigate to your directory and in the cse113/lab1 directory, save the history file with name lab1. This will create a file named lab1.hist. This is the file you will submit for this assignment.


Submission

You will submit the lab1.hist file for this assignment. The process for submitting your work can be found here. ABSOLUTELY NO submissions will be accepted any other way than the way described on the webpage referenced previously. No excuses are acceptable. Make sure you know how to submit well in advance of the deadline. You can practice submitting your work. Later submissions simply overwrite the previous submissions. You can check to see if you've submitted your work by using the Submit Inspector page.


Due date

Your lab submission is due no later than 11:59:59 pm on February 6th. Remember, no late labs will be accepted.


Working outside of Bell 340

If you would like to continue this work outside of Bell 340, there are a few options available to you. You can work in Bell 101, which is an engineering public computing site. Information about the differences you may encounter when in Bell 101 (note especially how to submit) are located here.

If you want to work on your own machine, totally independent of the lab environment, you will need several things:

A Java compiler. Download and install from http://java.sun.com/javase/downloads/index.jsp. You want the Java SE Development Kit (JDK) 6. YOU WILL NEED TO READ THE INSTALLATION INSTRUCTIONS posted here. Click on the operating system you will be using. It is especially important to read the step called Update the PATH variable. It claims it is optional, but I have found very few people who have not needed to do this step. So, I would STRONGLY encourage people to read these instructions and follow the directions for permanently setting your path variable. If you are using a Mac, my understanding from an article posted here is that you do not need to do this step.

The ability to use DrJava on your machine - download and install from http://www.drjava.org/. You will be downloading an executable. Once it is on your machine (I would recommend putting it on your desktop), you can simply double-click to start DrJava.

A set of library files so that you can use the Turtle and other objects. Download this file http://coweb.cc.gatech.edu/mediaComp-plan/uploads/101/bookClasses10-1-07.zip, save it to your machine and unzip it to a location that you will remember later.

Set up DrJava so that it can use the Turtle. Open DrJava, Click on the Edit menu and then on the Preferences Menu item. A dialog box will appear. It will look like this (except all fields will be blank):

Preferences Dialog

You will want your dialog to have a directory in the Extra Classpath text area when you close the dialog. In order to do this, click the Add button and navigate to the place where you unzipped the book classes you just downloaded. You need to make sure to click until you have the directory bookClasses in the path. When you are done with navigating the proper place, you should see a line similar to the one in the picture above. Click OK to close the preferences dialog.

Programs that will allow you to transfer files, and connect remotely to the Engineering servers. You will need to download the VPN client with XWin32 using the instructions posted here. You will also need to install Filezilla, using the instructions posted here.

Once you have completed the steps above once, you will not need to complete them again.

However, in order to work on your assignments, you will need to know how to start DrJava and save your files. Once you have saved your files, you will need to follow the directions for submitting an assignment as described above. These steps will repeat each time you work on the course assignments.


Lab authored by Adrienne Decker

CSE 113 - Spring 2009 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@cse.buffalo.edu | 130 Bell Hall | (716)645-3180 x 161