CSE 221 Lab 2
Table of Contents
Objectives
-
Familiarity with writing an interactive C++ main program using input/output
streams, iteration, and user-defined operations.
-
Familiarity with using specifications of global operations and implementing
operation bodies in C++.
-
Familiarity with compiling, linking, and executing a C++ program.
- Familiarity with using Text objects and operations.
The Problem
The problem is to implement another new Text operation called Split.
We will provide you with the test driver for the Concatenate
operation. As part of this assignment, you
will need to modify the Concatenate test driver to create a similar test driver
for the Split operation.
Set Up
- In an xterm window, create a new directory (folder) for this lab by
typing the "make directory" command:
mkdir lab02
- Change or move to the new directory (folder) for this lab by
typing the "change directory" command:
cd lab02
- Copy the catalog for this lab by typing the "copy" command:
cp -R /class/sce/now/221/labs/catalogs/lab02/* .
NOTE: The period . is part of the command. It denotes the current directory (folder).
- To see what was copied, type the "list" command:
ls
In particular, notice the two items
- Concatenate_Test_Driver.cpp
- Split_Header.h
How To Proceed
- Change the name of the file Concatenate_Test_Driver.cpp to
Split_Test_Driver.cpp by typing the "move" command:
mv Concatenate_Test_Driver.cpp Split_Test_Driver.cpp
(This command essentially says
"move Concatenate_Test_Driver.cpp to
Split_Test_Driver.cpp". This has the effect of changing the name
Concatenate_Test_Driver.cpp to the name
Split_Test_Driver.cpp.)
- Open the file Split_Test_Driver.cpp in xemacs by typing the command:
xemacs Split_Test_Driver.cpp &
- In Split_Test_Driver.cpp, replace the
global-operation header and contract for Concatenate
with the global-operation header and contract for Split.
The header and contract for Split can be found in the file
Split_Header.h.
- Provide an EMPTY procedure body for Split.
- Appropriately modify program_body main for Split_Test_Driver.cpp
so that it becomes a test driver for Split instead of a test driver for
Concatenate.
- Run the test driver interactively to test whether program_body main of
Split_Test_Driver.cpp interacts appropriately with the user and with Split.
- Provide an actual implementation (procedure body) for Split.
- Run the test driver interactively to test your implementation of Split.
What To Turn In
We want you to submit your lab02 catalog which includes the file
Split_Test_Driver.cpp. First, ensure that you are in your
lab02 directory. Do a cd lab02 if you are not. Then, type the
rcpp-submit command:
rcpp-submit c221xx lab02
Type the rcpp-submit command EXACTLY
as instructed for the specific lab assignment. Look at the response you
get to make sure rcpp-submit worked OK. If you type anything wrong
-- upper case for lower case, incorrect file name, or whatever -- then
you'll get an error message.
Some things to know about the rcpp-submit command:
-
There are always exactly two names following submit in this
command. They are, in order:
-
A course/section identifier, which is of the form c221xx, where
xx is to be replaced by lower case letters designating your section.
-
An assignment identifier, which is generally of the form labyy,
where yy is to be replaced by the number of the lab assignment . Notice
that "lab2" is different from "lab02", so pay attention to the specific
instructions in your lab assignment.
-
Unless directed otherwise, you should put the files you need for each lab
assignment into their own directory. Then make sure you're in the directory
for the right assignment when you submit the files that are to be turned
in. The lab-specific rcpp-submit command given in the assignment
assumes that you are following this advice.
-
If your submission is successful then you will see confirmation on the
screen and will receive e-mail to this effect. This e-mail is your receipt,
so save it in case something later gets lost and you need to prove
that you submitted a particular assignment on time.
-
If your submission is unsuccessful for some reason then you will get an
error message right away and will receive e-mail to this effect. A copy
of any error-message e-mail is also sent to your instructor and grader,
so please don't keep typing an erroneous rcpp-submit command over
and over again, hoping it will start working soon; this is very annoying
not just to you but to your instructor and grader (who assign your grade)!
Instead, ask one of the lab monitors or consultants or a fellow student
to help you. The rcpp-submit command is a script located in
/class/sce/bin
After doing some clean-up of files that should not be submitted, rcpp-submit
executes the submit command. For more information than you probably want
to know, type the command
man submit
-
If you submit (successfully) more than one solution for a given lab assignment,
then each new submission completely wipes out the previous one.
So suppose you submit an assignment, then a bit later make some changes
to improve it and decide to resubmit. If it's before the deadline then
this is fine. Simply make sure that you resubmit all files, not just the
ones that were changed. If it's now after the deadline, however, then the
grader will only see your late submission. That is the one that will be
graded and you'll receive late credit. A conclusion you can draw about how submit
works is that it never hurts to submit early, no matter how lame or incomplete
this first submission is. Submit early and often.