|
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 4 |
No! These are for testing purposes. Just have one line of code that
sets the head to the variable passed in or sets the tail to the variable
passed in.
NO. You should be able to use string methods and operators
to get the sort to work correctly. For example the "<" and ">"
operators give the correct results.
v1: we -> are -> UMD -> CS -> students -> we -> are -> brilliant ->
after sort() will look like:
v1: CS -> UMD -> are -> are -> brilliant -> students -> we -> we ->
It turns out you DO have to have primary.input included
in p0.tar in order to successfully submit. This is a mistake on
our part but it is relatively easy for you to inlude this one
extra file. So let's go ahead and do it.
The dummy node is not created until you have at least one
node in the linked list. It is deleted when your list is empty.
For this version of the code, just get the [] to work for accessing
the element at v[i]. That means walking down the linked list until you
find the ith element (remember we start at element 0) and then returning
the contents of that node.
Yes and largest() returns the alphabetically largest string in the
vector.
Yes! You are making a copy of "other" not copying to "other"
Yes!
Just like with real vectors, the iterator "it" is always sitting on
the 2nd iterator in the range so if your vector look like and you execute "hi" is not found in the range [v.begin(),v.begin()+2) so "it" is
sitting on "v.begin()+2"
You MUST assume that my code is good because I have written and
tested this code before posting the project. So when you run into a
problem like this, assume you need to do something differently than you
are doing.
One of my jobs is to expand your coding knowledge so we might do
things a bit differently than you expect, but hopefully it will be a
learning experience for you.
As explained 2 paragraphs below, the cxx compiler will give you a
little bit of trouble about the return value of & if you declared a local
variable, so declare a type & variable and return the variable. Now
you are returning a reference.
Since this operator returns a string * that means that if
"it" is the name of your iterator, you can use it->method() The cxx compiler will give you a little bit of trouble about the
return value so instead of one line of code you will need 2. Please note that the original header of this method is unchanged.
It still return string *.
Well, I have changed the Node.h to
have a #include <string> after the #ifndef NODE_CLASS and
#define NODE_CLASS
Download the newest copies of the .h files.
They return the smallest/largest string in the linked list. These
can be used for sorting.
If your prefer to write your own private methods that return
something else for the sort method that is fine.
Ideally you would throw an exception when the iterator walks off the
end of the Vector, but we are not teaching exceptions yet, so you can do
an exit(1).
Just like in the dictionary, uppercase "C" is less than lowercase 'c'
and "we" is alphabetically before "we " and "wet".
This is not really a mutator. I meant for it to add or subtract
from the count. So if "count" is 10 and you pass in -2, "count" will be 8.
If "count" is 10 and you pass in 4, "count" will be 14.
I'm not certain what I was thinking of for this function but we
will just live with the definition.
If you are getting a warning when you call getWord() in Node, there is
a way around this without changing the Node.h file.
Scratch the suggestion below about
putting #include <string> in Node.h TEMPORARILY.
It would be safer to do the following:
Your Node.cpp file should look like the following:
No. On the cxx compiler, because we are not calling any string
methods here, the code compiles just fine without that library. You should
note that in Iterator, the string library is included so when everying is
compiled, you will have a copy of that library's definitions.
But if you are working on a compiler other than cxx and it complains, put
#include <string> in Node.h TEMPORARILY and then remove it when you
upload
your program to the detective cluster for submitting.
A FAQ is a list of Frequently Asked Questions
and in particular the FAQ's for projects in this class will have
questions listed in reverse chronological order (meaning the most
recent question will appear at the top of the FAQ list and the
first question asked/answered will appear at the bottom of the
list).
Note that the FAQ's that are posted are usually ones that the
instructional staff have created in anticipation of potential
questions and ones that have been encountered frequently by the
instructional staff while assisting students in office hours.
Per the policies outlined on the syllabus you should see one of
the instructional staff during office hours regarding all questions
on projects - this includes project #0. Note that any email
inquiries concerning projects may go unanswered.
Also you should always read the corresponding FAQ prior to asking a
question on a project and you should generally ask no questions the
first day that a project is posted - rather you should thoroughly
read over the project description and think about it for a while.
Project #0 is due by 11pm on Friday, February 6th, 2004.
Note:
any project may be turned in late up to 2 days as specified on the
class syllabus. If you submit after 11pm on Feb 8th, your
project will receive zero points. For details regarding the late
policy and any penalties associated with submitting late projects
please see the class syllabus.
we -> are -> here -> not -> there
it =
find(v.begin(),v.begin()+2,"hi");
to operate on string methods such as it->length() which should return
the length of the string in the node (in the Vector) to which it points.
One to
assign the current word into a variable, and then return a reference to the
variable.
and before the class Node{
BUT you still must
implement smallest() and largest().
Node *walker = &A;
cout << walker->getWord() << endl;
Note that A is a Node.
#include <string>
#include "Node.h"
|
See the class syllabus for policies concerning email Last Modified: Thu Sep 11 12:29:30 EDT 2003 |
|
|
|
|
|