CS 102 lab2



Introduction:

In this lab you will create and send messages to objects. You will also implement the composition relationship. You will take existing code and complete the implementation of a window that pops up with the Italian flag.

Objective:

The high level objectives of this lab are:



Preparation:

Before you begin, look over your notes, look through chapter 12 of the book on object, and ask about anything you don't understand.
This lab must be done on eagle (the library that I'm using for x windows graphics is there) so get comfortable with eagle.

You have all been given a CD with x-windows on it for MS windows, so you can work on this lab outside of class as easily as inside of class.

To start:



Getting the files.

now copy the lab skeleton files to your directory:

cp ~jsantore/lab2Skeleton.zip .

unzip the skeleton files into your account.

unzip  lab2Skeleton.zip

Examining what you have:

move into the lab2 folder that was created when you unzipped the file.

cd lab2


Beginning the Project

lab2 uml

Now look over the files; they are all files containing classes. There is a header to each cpp file. Compare the code to the UML diagram shown above. There are some items from the flag class that are not shown on the UML. You will need to finish the code before you are done. In particular you will need to implement the has-a relationships between the Flag object and the three XXXBar objects.

Beginning your Coding:

Create the flag.

Begin by creating a flag object in the main function. Then call the initWindow() method on it.

Compile your program (see directions below) and then run it. You should see something like this
Lab2 after creating just the flag object


Code the relationships:

    Continue by implementing the three has-a relationships. The Flag is composed of three bars, a left bar, a middle bar and a right bar

When you have implemented both parts of the has-a relationship, you need to uncomment three lines in the Flag's initWindow method shown below (the three lines in red are to be uncommented. These lines do important setup work that cannot be done until the composition relationships are completed.

  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  //The area that you need to uncomment out is listed here
  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  //_left.setup(this);
  //_mid.setup(this);
  //_right.setup(this);
  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  //The area that you need to uncomment out is listed above
  //////////////////////////////////////////////////////////

At this point compile and run your program. If you have implemented the relationships correctly, your program should look something like this:
lab 2 flag

Compiling your code

We are using a utility called make to compile the files for this lab. Make in a nice utility that allows you to specify which files should be compiled for each project and how to compile them. To compile your project simply type at the command line:

make lab2

this will compile any files that need it and link the entire project and produce an executable program called lab2 that you can use. The skeleton files compile when you first get them, but the program doesn't do anything. There is no need to understand the intricacies of the makefile or make system at this time.

Submitting:

What to submit:

You need to submit all your source code for this project, along with the makefile and a README.txt file
The README.txt file should contain the following information.


When you are ready to submit, zip up your lab2 directory

zip -r Lab2Solution.zip lab2

Due Date:

Due by Midnight Wednesday Oct 12th.