CSE 115 - Spring 2007 - Banner
   CSE 115 - Spring 2007 - Introduction to Computer Science for Majors I
CSE 115 - Spring 2007 - Left Navigation CSE 115 - Spring 2007 - Lab 2

Lab 3

Introduction

In order to successfully design and built large software systems we need to manage their complexity. We will do this by designing systems so that they are composed of small, independent parts with well-defined responsibilities which interact with each other. These small simple parts can be developed and tested independently of each other. The complexity of the software system as a whole arises from the interconnections and interactions amongst the component pieces.

In lecture we discussed how to model systems of interacting entities in terms of their properties (or characteristics) and their capabilities (or the services they can offer to other entities). The capabilities of objects determine how they can communicate with each other. The relationships which a given object has with other objects determines which objects it can communicate with.

In lecture we explored one of the relationships which objects can have with each other. In this lab we will focus in particular on the instantiation dependency relationship. The instantiation dependency relationship exists between two objects when one object uses another object in some way. It is for this reason that the relationship is sometimes called the uses a relationship. This relationship can be expressed in Java by simply having one object create a new instance of the other object.

We have spent this past week learning about methods and how to use them to communicate with our objects.  We have also learned that objects can have a common interface.  If objects share an interface, then we know something about the capabilities those objects had in common.  We might not know exactly how a particular object will react to a particular message, but have the important knowledge that an object CAN react to that message. 


Objectives

The high-level objectives of this lab are to have you,
  • use instances of classes that share a common interface
  • call methods on objects
  • implement a design which is provided to you in the form of a UML diagram.
The following are the new concepts covered in this lab:
  • calling methods,
  • passing parameters.
  • modeling the uses a relationship using object dependency

Assignment Specifications

The fields of DNA analysis and forensic science are exploding with interesting problems to explore.  From mapping the human genome to solving the crime of the century, these fields have taken over the spotlight in recent times showcasing where real cutting-edge discoveries are happening often.

For this lab, you will play the role of investigator, analyzing a set of unidentified cells and observing their behaviors to try to help determine how the cells react under certain circumstances. 

What do we know about cells?  Put away your Intro to Bio textbook, and instead, look here at the ICell interface.  All cells will implement this interface and have each of these methods defined on them.  Let's take a moment to discuss each of these methods now.

public void grow()

Given the right circumstances in a laboratory environment, cells can grow.  Luckily for us, the Applet class in Lab 3 provides such an environment for our cells.  Asking a cell to grow will enable you to see the unique way that each cell changes as it grows.

public void die()

We can also contribute to the death of our cells in the laboratory environment.  When we ask cell to die, you will be able to see the unique way in which each type of cell dies.

public void stain (graphics.colors.Color color)

When looking at our cells, it is often times better if we can stain or die them a particular color so we can see them better during observation.  This method will allow us to give a color of our choice to our cells.  Note that some cells accept stains and change colors, while other cells' behavior can be far more elaborate.


Helpful Hints

Read through the entire lab before you start working, so that you know what to expect. Make sure you save your work often, and keep track of what you are expected to submit.

Do not be afraid to refer to earlier labs to recall what things mean or what commands are available for you to use.  It might be especially important to refer back to Lab 2 for information about checking files out from the repository and Jarring and submitting your work.


Reading

Make sure you have read chapter 2 and 3 of the book before coming to lab. Also make sure you have reviewed your lecture notes.


Lab set-up tasks (If you are working at home see these directions for this lab)

At your lab session your teaching assistant will briefly discuss how to carry out each of the set-up tasks below. She or he will also be available to answer questions you might have. Before you start work on the lab itself, you must carry out each of the following set-up tasks. Your teaching assistant will guide you through this process.

Step 1: Log in

Step 2: Start Eclipse

You may have an icon on your desktop that you can double-click.  If you did not set that up in Lab 2, you will need a terminal window and will need to type eclipse at the prompt.

Step 3: Check out Lab3 project from LabSkeletons repository

Click on your CVS view (or open it if it is not already open) and open the LabSkeletons repository (click on the "+" or triangle to the left of its name to "spin" it open). Open "Head", and then select Lab3. Now right-click on Lab3, and select "Check out".  The Lab3 project will appear in your workspace.


Lab Design

Now you're ready to start working on the lab itself!

It is important to come up with a design for your program prior to writing it. The UML class diagrams introduced in lecture will help in this endeavor and will be central to discussions throughout the class. Right now we want you to understand how to take a UML class diagram that includes the dependency (uses a) relationship and generate Java code for that. Since it is still early in the semester, we will help you create the UML that your lab should implement. Your submitted lab must implement the UML class diagram discussed in recitation. As the semester progresses, you will be responsible for coming up with your own design for your projects.

 

Using Green to create your UML diagrams

Step 1: Make local plug-ins available

To do this, go to "Help" -> "Software Updates" -> "Manage Configuration".

This will open up the "Product Configuration" window.

Select "Add an Extension Location" from the right-hand window. You will see the following window:

Click on "Filesystem" in the left-hand pane and browse to /projects/CSE115/eclipse

Once you've done this, click "OK". After you click "OK" Eclipse will ask whether to restart the workbench:

Click "Yes" to restart the workbench. When you do, your Eclipse window will disappear for a little while, then Eclipse will start up again.

Open the Applet class in the Java editor

Open up the Lab3 project, and then the lab3 package. Double-click on the Applet class in the Package Explorer. The Java editor will open on the Applet.java file in the center view. Notice that the Applet has no statements in its constructor.  You should fill in the comments for modified by with your name.  You should make sure that your name appears in all the files that you write this semester.

Open Applet using Green

Right click on the file Applet.java in the Package Explorer and select to Open in UML class diagram. You will see a diagram that contains the class box for Applet.

Create CellObservatory Class using Green

Click on the Class box button in Green and then click on the canvas to create a new class in the diagram. You will see a "New Java Class" window open. In this window you need to enter the name of the new class your are creating, in the field labeled "Name:". You should type: CellObservatory.  Look at the screen shot below and make sure yours matches.

Click "Finish" when you've entered the class name.  A new class will appear in the Green editor. It will also create a file named CellObservatory.java in your project.

Create the Dependency Relationship between Applet and CellObservatory

Now you will create your first class relationship! In the Green editor, select the dependency relationship button. Click on the Applet class and then click on the CellObservatory class. The Dependency relationship arrow will appear and the relationship will have been created for you in the code. Open the Applet.java file to see the code that was inserted when you created this relationship.

Run Your Code

You have created a relationship, which is a major change to your code. It is a good idea whenever you make a change like that to run your program to see what changes you have made and if you have still retained the functionality you had previously. Run the Applet. If you don't remember how to run your project, refer back to Lab 2. When running this lab, you should set your size preferences to 750 wide by 300 tall to see the entirety of the cell observatory. If you do not remember how to do this, refer back to Lab 2. At this point, you will not see anything in the Appletviewer window. That is because we need to add the cells.

Modify the CellObservatory class

Inside the CellObservatory, you will get three instances of objects that implement the ICell interface and on each one call one of the methods that ICells have defined on them.  Note that you should make a different method call on each of the three instances of ICells in your CellObservatory.  The order in which you call the methods is up to you. 

Remember that if a method takes a parameter, you will need to pass the appropriate value for that parameter.

Getting the cells to call the methods on will be accomplished through the use of a RandomCellGenerator.  Take note of the class lab3lib.RandomCellGenerator.  This class has a method defined in it called randomCell().  Every time that method is called, it returns an instance of a cell that implements the ICell interface.  You will make three calls to this method to get your three cells.

You should be sure to check out all of the Javadocs for the Classlibs.jar, located here.

Build up the Code Incrementally

Building a little of the code and testing it as you go is an important habit to get into that will help you as the projects get larger throughout the semester. Create one cell and call one method on it, and run your code again.  Continue in this manner until you have all three cells and have called all three methods.  Notice that each time you run your program, you will get a different set of cells in your observatory.


What you hand in

When you are finished, you need to export your solution from the Eclipse environment so that you can submit it.  You need to follow the same steps as you did for disconnecting from the repository and exporting as you did in Lab 2.  If you are not sure how to do this, please refer back to those instructions.  This time, you should name your Jar file Lab3.jar.

Then you can submit the Lab3.jar file using the electronic submission program.  If you do not remember how to use the the submission program, refer back to earlier labs.


Due dates

You have one week from the meeting of your lab to submit your solution.  The due dates are summarized in the table below. You are always welcome to submit early. If you submit more than once, the later submission will simply overwrite the previous one.

To check that your lab was submitted, you can always refer back to the Submit Inspector on the Resources page of the website. After you have entered your user name, your submissions will be shown. Clicking on the name of a file that is a zip file will show you the contents of the zip file so you can verify that you indeed zipped up all the correct files.

Date of lab Due date for electronic submission
Tuesday, February 6 Monday, February 12
Wednesday, February 7 Tuesday, February 13
Thursday, February 8 Wednesday, February 14
Friday, February 9 Thursday, February 15

 

CSE 115 - Spring 2007 - Footer

 

 
Last modified: Sat Feb 3 16:29:08 2007
© Adrienne Decker