CS 102 LAB2 Using Objects.
Introduction:
In this lab you will create and send messages to objects. You will also
implement the composition and association relationships. You will take
existing code and complete the implementation of a simple lava lamp
simulation in which a bubble will rise at a keystroke.
Objectives:
The high level objectives of this lab are as follows:
- To begin working with objects in C++
- To create an object
- Invoke a method
- Read and understand UML
- Implement the Composition and Association relationships.
- Implement and use an accessor method
- Implement a destructor
Preparation:
Before you begin, look over your notes, look through chapter 12 of the
book on object, and ask about anything you don't understant.
This lab must be done on eagle (the library that I'm useing for
terminal graphics is there) so get comfortable with eagle. Check the
"cheat sheets" on the web page if you need to.
Lab Tasks:
login to eagle.
You can either use PC320 from one of the BSC lab machines, or
hyperterminal from home. This lab
will not work with the dos command line in windows. So make sure
you use something different.
If you use hyperterminal, you'll need to configure it as below.
- When it starts up and asks you for a connection name, call it
eagle
- At the next dialog go to the "connect using" menu and select
"TCP/IP (winsock)"
- Now one of the fields says "host name" use eagle.bridgew.edu
- Click ok
- Now select <file><properties> to bring up a
configuration dialog
- Click the settings tab
- There is a menu item called Emulation, change it to VT100
- exit hyperterminal, saving your session when promted and then
start it again
- You can now connect to eagle using that session without
performing this configuration again.
Setup account:
Now that you are logged into eagle setup your account.
So that you and I see the same things, use the following commands to
setup your account:
cp
/export/spare/faculty/jsantore/.emacs .
cp
/export/spare/faculty/jsantore/.tcshrc .
now run the tcsh shell by typing tcsh at the command line.
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
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
below. There are some inconsistancies and some items are simply not
shown on the UML. You will need to fix the inconsistancies in code
before you are done.
Beginning the project.
Below is the UML for your project:
Note that there are some aspects of the LavaLamp class that are
deliberately left blank or Omitted. You will have to fille those in.
The relationships in the diagram should help you to understand what is
missing. Look at the diagram and decide what is missing.
Beginning your Coding:
Code the relationships:
Begin by implementing coding the LavaLamp's knows-a relationship. Add
the two parts needed to implement the knows-a
Next implement the three has-a relationships.
Create the lavaLamp:
Now go to the main function and create the LavaLamp and any other
objects that you need to create in order to properly create the
lavalamp.
Let your char-bubbles rise:
When the space button is pressed, the method/member function spaceBarPressed
in the KeyHandler
class is called for you. (you don't need to call it, it happens
already) You do however need to implement this method so that it
animates a bubble of the appropriate character.
How does it know what character to use? what object knows what
character should be used?
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.
- 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
and submit it using a method that I'll inform you of the week the lab
is due.
Due Date:
By midnight, Friday October 8th. Due By
Midnight Tuesday Oct 12th