This lab will be posted in two parts, one part to do each of the two weeks you have to complete the assignment. In the first part, you will be asked to create a Java source code file, reusing much of the code you worked on for Lab 2.
You will be editing source code using the Eclipse editor and using the DrJava interactions pane to create an instance of the object you've defined in your class file.We will concentrate on the following ideas that were discussed in class:
Check out the Lab3 Skeleton from the repository. In the skeleton, you will find a package named interiordecorator, which contains the files you worked with last time to create a room at the DrJava interactions pane.
Select the interiordecorator package. Right click and select "New", then select "Class". The new class dialog will appear. You should fill in the name of the class you wish to create. Name your class MyRoom. Ask your TA to come over to see that you have completed up to this step to earn credit for attendance for this week in recitation.
When you select "Finish" in the dialog, you class will be created and opened in the editor. You should fill in the constructor of the MyRoom class to do the following (the same thing you needed for Lab 2):
interiordecorator.Room
object. You can specify a color for the room by creating a new color object in the ()
when you create the roomaddCurtains,
and specify a color for the curtains by creating a new color object in the ()
of the method callCouch
, Lamp
, Plant
, Table
) by calling the add method on the room you created.setLocation
), change its size (setDimension
), or for some really funky rooms: change its rotation (setRotation
).After you have completed this and ensured that there are no syntax errors, you should create an instance of the class you just created at the DrJava interactions pane. To be sure that DrJava recognizes the changes you made, right click in the DrJava interactions pane and select "Reset Interactions" to make sure your new class definition is recognized.
You will do the following using the same skeleton you have from last week. Create a new package in your project and name it drawing. In the drawing package, create a class named App.
You App class is the main class for a program that creates a JFrame with a drawing in it. The drawing can be of whatever you'd like, but your drawing must contain the following elements:
Your program can contain more than the required components, but must contain at minimum these components.
You can find information about the different graphics available to you here.
You will submit your Lab 3 assignment after you have completed both parts of the lab using the Web-CAT submission plugin from Eclipse. The entire lab work will be due the day before your recitation meets the week of February 22nd. For your reference, consult the table below for due dates.
Recitation | Lab 3 due |
---|---|
A6 | Sunday, February 21st at 11:00pm |
A1 | Monday, February 22nd at 11:00pm |
A2 & A5 | Tuesday, February 23rd at 11:00pm |
A3 | Wednesday, February 24th at 11:00pm |
A4 | Thursday, February 25th at 11:00pm |
If you are attempting to work at home, you will need to make sure you have the image files couch.gif
, lamp.gif
, potted-plant.gif
, and table.gif
in a directory on your system named /projects/CSE115/Images
where /projects
is in your root directory (probably C:\
if on a Windows system). You can get the files by using a file transfer client (like Filezilla). The image files are located on the server (timberlake.cse.buffalo.edu
) in a directory named /projects/CSE115/Images
. If you did this for the last lab, you do not need to do it again.
Images from http://free-clipart.net/, http://www.webweaver.nu/, and http://classroomclipart.com
Lab authored by Adrienne Decker
Page maintained by Adrienne Decker
Contact: adrienne@buffalo.edu | 130 Bell Hall | (716)645-3184