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

Lab 3

CSE 115 - Spring 2010 - Lab 3

Introduction

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.


Objectives

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:

  • Creating objects
  • Calling methods
  • Using variables that hold references to objects
  • Creating a class definition
  • Defining a constructor

Lab Tasks (Week 1)

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.

Creating your first class

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):

  • Create a interiordecorator.Room object. You can specify a color for the room by creating a new color object in the () when you create the room
  • Call the method addCurtains, and specify a color for the curtains by creating a new color object in the () of the method call
  • Add at least two pieces of furniture to the room (Couch, Lamp, Plant, Table) by calling the add method on the room you created.
  • For each piece of furniture added, you should change one of its defaults by calling one of its methods. A complete list of methods you can call is available here. Probably the methods of most interest to you are ones to move the furniture (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.

 

Lab Tasks (Week 2)

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:

  • A DrawingCanvas (you can't put any graphics on the JFrame without it)
  • An instance of at least two different graphical components that have had their default size, location, and color changed.

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.


Due dates

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

 


A Note for Working at Home

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.

 

CSE 115 - Spring 2010 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@buffalo.edu | 130 Bell Hall | (716)645-3184