CSE 115 - Fall 2008 - Banner
UB -
University at Buffalo, The State University of New York Computer Science and Engineering
  • CSE 115 - Fall 2008
CSE 115 - Fall 2008 - Navigation
CSE 115 - Fall 2008 - Lab 3

Lab 3
Last modified: September 14 2008 04:41:57 PM

- - Lab 2

Introduction

In this lab, we will actually be writing some Java code that will be executed in the DrJava interactions pane. We will be focusing on some simple ideas for the next two weeks so that we can combine them into larger and larger programs starting with Lab 5.


Objectives

You will be interacting with the DrJava interactions pane and executing some Java code that you will write. We will concentrate on the following two ideas that were discussed in class:

  • Creating objects
  • Calling methods


Lab Tasks

Practice what we've already done

Now it's time for you to do what we have been doing in lecture together. You will create a Terrarium and Ants. To ensure that you are able to execute the commands, check out a version of the Book Chapters into your workspace using the same method as checking out the Lab 2 skeleton. Note that the Book Chapters come from a different repository than the lab skeletons, but the procedure is the same.

If possible, try to do the following without relying on looking at the "answers" before you type:

  • Create a chapter1.Terrarium (no ants yet)
  • Call the add method to add a chapter1.Ant to a different chapter1.Terrarium (one ant, not moving)
  • Call the add method to add a chapter1.Ant to a different chapter1.Terrarium and have the ant start moving

If you have trouble doing any of these, you can refer back to the end of Chapter 1 of the text online for assistance. You can also ask your TA for assistance. When you have all three Terrariums on the screen, ask your TA to come over and they will give you credit for this part of the lab.

Do Something Different

Check out the Lab3 Skeleton from the repository. You will not be editing any of the files in the Lab 3 skeleton, but if you are interested in how any of the code works for Lab 3, you are more than welcome to look at the code that you check out from the skeleton. You will type all the code for this assignment into the DrJava interactions pane and observe the results. You will be submitting a transcript of what you typed into the interactions pane as described below.

Becoming an interior decorator

There are two objects that you will create for this lab: decorator.Room() and one or more of the graphics.color.* classes.

You will need to create the following objects and call the following methods to complete the lab.

  • Create a decorator.Room object
  • Create another decorator.Room object and call the method addCurtains
  • Create another decorator.Room object and call the method addCurtains, but this time specify a color for the curtains by creating a new color object in the () of the method call
  • Create another decorator.Room object, but this time, specify a color for the room by creating a new color object in the () when you create the room
  • Create another decorator.Room object, specifying the color for the room and the curtains when you call the add method

Creating a transcript for submission

First, you will create a brand new Eclipse project named Lab3Submission by selecting File->New->New Java Project. You will then see the project in your workspace.

Then, select the name of the project by left clicking on it. Then, right click and select Import. Under the General tab, select Archive File and then hit Next. Browse for the file named Lab3Submission.jar in /projects/CSE115/Repositories/Fall2008/. When you have found it select Finish. You will be asked if you want to overwrite existing files - select Yes to All.

Now you will see a file in your Lab3Submission project named interactions.txt. Double-click to open the file in the editor. Highlight all of the text in the DrJava interactions pane and copy it. Paste it into the interactions.txt file. Save interactions.txt.

Export the Lab3Submission project as you did in the previous lab. Submit the Lab3Submission.jar file using the electronic submission command.


Due dates

Some of the lab is due in lab time and there are other parts that you must submit. The Lab3Submission.jar must be submitted using the electronic submission command by the end of the upcoming weekend, so by 11:59:59pm, Sunday, September 21st.


A Note for Working at Home

If you are attempting to work at home, you will need to make sure you have a file named Classlibs.jar in a directory named /projects/CSE115/Classlibs/Fall2008 where /projects is a directory in your root directory (probably C:\ if on a Windows system). You will also need to make sure that you have a the image file couch.gif in this same directory. Both can be transferred using a file transfer client. They are located in the same directory on our server as the one that you need to set up on your machine.

 

CSE 115 - Fall 2008 - Footer

Page maintained by Adrienne Decker

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