|
C M S C 2 1 4 C o m p u t e r S c i e n c e I I S p r i n g 2 0 0 2 |
For some reason, the makefile doesn't recognize aliases. We have "aliased" cxx to be cxx -w0 -std strict_ansi. So, you should modify your Makefile to use cxx -w0 -std strict_ansi, instead of just plain cxx.
The first test you should run is to determine if the MovieSortedList
object contains the same number of elements as the VERIFY command. If not,
you can immediately return false.
You should create a Movie object (as a local variable, without
dynamic memory allocation), and pass in the title from the VERIFY input.
The earnings can be set to anything.
Compare this to the movie in the MovieSortedList which you
can access by using ConstIterator. You can dereference the
iterator (as in *iter) to get the Movie object and
compare it to the temp Movie object created earlier, to check
if the titles are the same. You can use the -> operator
to access the getEarnings() method to check if the earnings
are the same.
This should be done in a loop, where the temp Movie object is
declared inside the loop, and is reset to the next Movie in the
VERIFY list on each iteration, and the iterator is moved forward
by 1 at each step, until you go through size() iterations.
Don't use contains() because it won't check for correct
order. You need to use the iterators to process the list.
The warning is caused by the constant "true" in the while loop.
To get rid of it, do the following:
Nested classes should be commented, but they are short, so the
comments should likewise be short. Only comment the new things
added to the tester classes. You don't have to comment parts
of the code you didn't write.
It will appear as "NONE" 0 in the list where "NONE" is the
title, and 0 is the earnings. We will not try to change the earnings
of a movie title called "NONE".
There is a one day extension for Project 1. Project 2 will
be posted Wednesday evening, as a result. Standard penalties
(as described in the description) will hold for 1, 2, and 3 days
late starting after 11 PM on Wednesday evening.
At the very least, the input file will contain <cmmdlist>,
blanks, and </cmmdlist> (as described in the BNF).
Also, for the VERIFY, there can be a <list>,
followed by blanks, followed by </list>. In that
case, either the MovieArrayList or MovieSortedList
must be empty for it to match.
Since both MovieSortedList and MovieArrayList
really contain 3 classes, not just one, you should have your
file in three sections. For example,
Yes. The project description says to go one past NULL, but
as it turns out, that won't behave correctly. The description
is being revised to correct this. As a result, we won't test for
this condition (i.e., empty MovieArrayList with iterators) until
Project 2.
The InputTokenizer (used in main.cpp) breaks apart
words with one or more white space and stops at </cmmd>.
Anything in between (except strings that begin and end in double
quotes) are broken up using this rule. Words beginning in double
quotes are read all the way to the close quote, with both quotes
disposed of.
The BNF is incorrect. It has been fixed in the project description
(in green). SORTED VERIFY commands with "add", "remove", etc. should
only have one variable.
More hints are posted in the posting account in a file
called README.MovieTester.
Initially, do the following: number the "tokens" in each command as
shown in class. Assume they go into a variable called list in
main.cpp, then start to trace in MovieTester.cpp under
run() method. See where this leads you.
The primary input and primary output files have been posted in the
posting account (under the Projects/P1 directory) and online on
the main project webpage.
The submit command is now working for project #1. If you encounter
problems submitting be certain that you read the messages that the
submit program prints out to the screen. Also check the _Submit
directory in your account and the logfile to make sure it worked.
This is a little tricker than expected. Consider the following.
If you are implementing a method in Foo and have a parameter or local
variable of type Foo, you are allowed to access the private
data member of Foo. Now, consider the fact that makeConstIterator
will allow you to create a ConstIterator object within
a ConstIterator method. Does that help?
The runTestDriver() code is code that tests your
class. You should check to see if assignment, copy, and other
methods work. You only have to do it for three classes:
Movie, MovieSortedList, and
MovieArrayList. It is optional to do it for:
MovieTester, MovieSortedListTester, and
MovieArrayListTester.
The goal of runTestDriver() is to have you test your
classes, and show some evidence you have done so. While you
may feel the lack of importance in testing classes, it should
be considered part of writing/debugging a class. The "Tester"
classes are merely an extension of the idea of writing driver
classes, albeit a more complicated way of doing so.
Such tester classes would be good if you needed the classes
to work for a long time, and if they were sufficiently large
code. That way, you could check to see if any fixes or improvements
to the code actually helped.
A small one. print() and the output operator have
been added to MovieArrayList.h to make it conform
to the project description.
Also, you are ALLOWED to add a PUBLIC static method called
runTestDriver() to your classes.
Yes, you can. The project description says MovieArrayList
are not sorted, and can contain duplicates.
When you see <list> .... </list>, there
will always be an even (possibly zero) set of tokens.
It alternates between titles of movies and earnings.
To successfully match the MovieSortedList (same idea
for MovieArrayList), you must have exactly the same number
of titles in the <list> .... </list> as you do in
the MovieSortedList. The earnings must be the same.
The order must be the same. Thus, if the <list> .... </list>
movies "Aliens" and "Alien Resurrection" with earnings 2000 and
3000, then the list must contain, in exactly the same order
"Aliens" and "Alien Resurrection", with earnings 2000 and 3000.
If the list in the input file and the MovieSortedList have
different number of movies, or the earnings don't match, or the
order of the movies aren't the same, then the VERIFY fails.
This is one way to test if your MovieSortedList has
the correct content.
Add the following method to your header file in Movie.h,
MovieSortedList.h, MovieArrayList.h. This is
in the PUBLIC SECTION (not private).
That should be "SimpleMap.h", not "Sorted.h". It will
be fixed momentarily.
First, read the file "README.strategy" in the posting
account. Then, trace out the code for the first few inputs,
to see what the code is doing. It's not SO complicated
once you see what's going on.
You can use the "transform" algorithm.
You need #include <algorithm> to use
transform
As an exercise, how would you convert the string to
uppercase?
The toInt() method has been updated in MovieTester
and MovieSortedListTester to handle negative numbers.
Please make those updates. Also, always read README.updates.
More changes have been made to the MovieTester.cpp and the
project description (all quite minor).
Also, there are minor BNF modifications. Please see latest
version of project. The changes have been highlighted in green.
Here are the (additional) assumptions you should make:
Many small changes have been made to the posted files.
Read README.updates in the posting account (or just download
newer versions as of Feb 19). Most of these changes are
namespaces changes.
There's a minor change to the PRINT output for Movie, in
the project description. It no longer prints "Title:" to make
it consistent with the rest of the project.
Yes, it's updated! However, due to the large number of text
written so quickly, there are bound to be small errors. Please
notify your TA of such errors, and they can talk to the instructors.
Also, new files have been posted. Check sample.input
and sample.output. These are not yet the primary input
and output, which will be posted later this week.
Finally, note that MovieArrayListTester is not implemented.
You have to do that. However, the primary input does not test
this (the secondaries will). Therefore, you will still be able
to successfully submit even if you are unable to complete this
class.
Also, read the update for how to submit your driver code. It's
been modified since the first posting of the project.
Yes, there can be spaces anywhere in the title, at the beginning,
middle or end, and there can be more than 1. They are blanks (no
tabs nor newlines in the title). No, there won't be a movie called
"NONE". However, when you do "resize" and the size increases on
MovieArrayList, it will create movies with title "NONE", since
the default constructor uses them.
Of course not, except if specified (for example, you are allowed to
add copy constructor/assignment operator/destructor, if needed). If
you think there's an error, i.e., the public methods ought to be
changed, then notify us, and we will correct the headers (and there
may be some problems to be corrected soon) and post the updates
to README.update (and to the FAQ).
No, that would defeat the purpose of writing MovieArrayList.
The MovieArrayList is basically an implementation of a vector.
To use a vector to implement a vector is not the point. So, don't do
it.
Yes, that was an error in the description. It's fine in
the header files, however, and you should return an int.
You should pass the title as a string (this is not the
proper title). Normally, you will be calling these
methods by reading some title from input, and passing it to
these methods.
The relational operators must call compare() which
will do the actual comparison. Pass the "this" object as the
first argument, and the "other" object (passed in as the parameter
in the overloaded relational operator) as the second argument to
compare. Use the result of compare() to determine whether
the operator is true.
The motivation behind this exercise is to see how a compare
function that returns -1, 0, 1 provides equivalent information to
all the relational operators.
If you're wondering why it's a standalone function, it's to test
your ability to compare titles by using only public methods of Movie.
And yes, you must use compare() to implement the relational
operators
If you know STL algorithms or other STL string/vector methods,
feel free to use them. That way, you learn more about how these
work.
You may use indexing to access elements of a vector, if
you want (or iterators).
Yes, and it will be fixed soon in the posting account. (Now fixed)
You may be somewhat stuck splitting string into words, but wish to
test the other methods of Movie first. You can, for the time
being, write a constructor that takes a vector of strings. This will
let you code up the rest of the class. Then, REMOVE this method, and
figure out how to split the string up into words.
You may assume a movie title contains at least one word. If that
one word is an article, then effectively the title acts
like an empty string (thus, a movie called "the" would be equal to
a movie called "an", and a movie called "the" would be less than
a movie called "the producers").
Yes, it was. Thanks to Dion, a CMSC 214 TA, there was an error in
the Node class of MovieSortedList. It didn't match the project
description, so it's been cleaned up now. If you copied the file
before 2 AM on February 13, you should get a new version now. Also,
MovieArrayList had repeated operator==()
and operator!=() in the Iterator nested class, which
have also been removed.
It's coming soon!
bool done = false; // declare a bool variable
while ( ! done ) // used to have "true"
{
// code
}
This should get rid of the compiler error.
Class: MovieSortedList
Class Invariants
----------------
// invariants for MovieSortedList
Data Members
------------
// data members for MovieSortedList
Constructors/Destructors/Assignment
-----------------------------------
// Constructors/Destructors/Assignment for MovieSortedList
Mutators
--------
// Mutators for MovieSortedList
Accessors/Queries
-----------------
// Accessors/Queries for MovieSortedList
Verifiers
---------
// Verifiers for MovieSortedList
=============================
Class : MovieSortedList::Node
=============================
Class Invariants
----------------
// invariants for MovieSortedList::Node
Data Members
------------
// data members for MovieSortedList::Node
Constructors/Destructors/Assignment
-----------------------------------
// Constructors/Destructors/Assignment for MovieSortedList::Node
Mutators
--------
// Mutators for MovieSortedList::Node
Accessors/Queries
-----------------
// Accessors/Queries for MovieSortedList::Node
Verifiers
---------
// Verifiers for MovieSortedList::Node
======================================
Class : MovieSortedList::ConstIterator
======================================
Class Invariants
----------------
// invariants for MovieSortedList::ConstIterator
Data Members
------------
// data members for MovieSortedList::ConstIterator
Constructors/Destructors/Assignment
-----------------------------------
// Constructors/Destructors/Assignment for MovieSortedList::ConstIterator
Mutators
--------
// Mutators for MovieSortedList::ConstIterator
Accessors/Queries
-----------------
// Accessors/Queries for MovieSortedList::ConstIterator
Verifiers
---------
// Verifiers for MovieSortedList::ConstIterator
Yes, verifiers are still optional for this project.
static void runTestDriver();
Then, in your ".cpp" file, fill in the code like:
void Movie::runTestDriver()
{
// put your driver code here
// shouldn't need modification
}
string s = "I AM Mostly in ALL CAPS";
transform( s.begin(), s.end(), s.begin(), tolower );
This operation transforms characters starting at
s.begin() (an iterator to the first character to
be transformed) and ending at one character before
s.end() (which is an iterator to one past the last
element of the string), and transforms each character
using the tolower() function (the fourth parameter),
and puts the result of the transformation to s.begin()
(the third parameter).
|
See the class syllabus for policies concerning email Last Modified: Sat Feb 23 11:48:11 EST 2002 |
|
|
|
|
|