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.
The high level objectives of this lab are:
To begin working with objects in C++
To create an object
Invoke a method
practice reading UML diagrams
implement the has-a relationship
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:
start x windows
open a terminal if one hasn't been opened for you
ssh to eagle as we did in class
ssh -X <eagle username>@eagle.bridgew.edu
start the t shell by running tcsh
now copy the lab skeleton files to your directory:
cp
~jsantore/lab2Skeleton.zip .
unzip the skeleton files
into your account.
unzip
lab2Skeleton.zip
move into the lab2 folder that was created when you unzipped the
file.
cd lab2
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.
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
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
_left
_mid
_right
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//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:
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.
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.
Your name
the name of each header/cpp file combo that you are turning in and the class it implements.
how to run your program.
What implementation decisions you made
If there is anything missing, incomplete or any bugs in your program
When you are ready to submit, zip up your lab2 directory
zip
-r Lab2Solution.zip lab2
Due by Midnight Wednesday Oct 12th.