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.
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:
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:
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.
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.
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.
decorator.Room
objectdecorator.Room
object and call the method addCurtains
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 calldecorator.Room
object, but this time, specify a color for the room by creating a new color object in the ()
when you create the roomdecorator.Room
object, specifying the color for the room and the curtains when you call the add
methodFirst, 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.
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.
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.
Images from http://free-clipart.net/
Lab authored by Adrienne Decker
Page maintained by Adrienne Decker
Contact: adrienne@cse.buffalo.edu | 130 Bell Hall | (716)645-3180 x 161