|
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 3 |
There is a small mistake with the complete.output file. In particular the second time s4 is printed out is should be:
s4 = "ng "In particular the complete.input file contains a NEWLINE character ('\n') immediately after Test*ng however s4 by default has the blank character as its DELIMITER and thus the following statement:
cin >> s3 >> s4;reads "Test*" into s3 (throwing away the *) and then ng AND the newline character into s4 (but doesn't throw away the newline character because it is not equal to the DELIMITER character.
The complete.output file has been updated to reflect the "correct" answer.
The reason the original complete.output file contained the answer that it did was because the program used to generate it MODIFIED the DELIMITER character of s4 to be the newline character when the following statement was executed:
s4 = (str1 + " " + str2);however you should not do this in the operator= function so the correct answer will be the new/current one posted (in complete.output).
Please re-read the course syllabus regarding email policies. Although it may not have been explicitly stated, DO NOT EMAIL PROJECT QUESTIONS AS THEY WILL GO UNANSWERED - if you have a question you must see someone in person during the posted office hours - even if it is the weekend or 2am in the morning - in which case you will need to remain patient, work on other parts of the project, study other material, work on other classes, or take a break. The course syllabus states that the email addresses of the instructional staff [this includes the TAs] are provided for emergency situations only.
So far several people have sent email about the project, most with "what if" or "can I" type questions:
Note: all students should strive to submit projects well PRIOR to the
11pm due time and if you are unable to, then fortunately you have up
to 48 hours to fix whatever problems may have kept you from submitting
ontime. Due to the fact that students are given ample opportunity to
meet with the instructional staff prior to a project being due, no
question regarding a project is considered an emergency situation.
An emergency situation would be if the class computer accounts were
encountering problems - if something like that does occur you should
check the class webpage (click on the announcements link and the FAQ
page for the respective project) and if the problem is not mentioned
there, then and only then should you notify the instructional staff.
Additionally, email is perhaps one of the worst
mediums/means for holding a conversation and many people think that
it is an instant medium. When adequately answering a question a
conversation is generally needed. Additionally, in the past there
have been MANY instances where someone asks a question via email (like
"the compiler gives me this weird error ... what is wrong?") and by the
time someone answers (assuming there is even enough information provided
to give a decent answer) the person has already figured out the problem
and responds back saying something to the effect of "Thanks but I already
figured it out, however there is a new error which says ... can you help
me?" !!!!
So the next concern might be to ask about a clarifying question
or a yes/no type of question - this is where the instant
medium becomes an issue - 1) we do not have the resources to
satisfy the instant wants of everyone and 2) it is not best
to do so - rather than "fire off" (send off) an email everytime a little
question pops up (like can I do this, what if this, how do I fix this, ...)
students should learn to think about their problem/question first and see if
they themselves can either 1) answer the question or 2) look up an answer
to the question (without violating the honor code). This is perhaps the
most important of items - attempting to think about the problem (do I
absolutely have to modify the header file, or is there any other way I
could do this that works per the project specifications? OR It appears
that I am having difficulty with the std:: portion of the
code - when do I need std:: and when do I not?, ...).
Hmm, so what about this violating the honor code issue. If you are
having difficulty with some part of the project it is recommended above to
attempt to look up an answer to the problem - using a textbook or
other such resource clearly does not violate the honor code - note however
if you copy code from somewhere (say you find code in a textbook) or use
a novel idea you found somewhere, it is always best to adequately cite
your source.
What about going to a friend and asking them to assist - this is where
the gray area begins and very quickly turns into a potential
violation. You are permitted to study together with other students
and if you are having difficulty understanding how a makefile works, how
namespaces work, how general sorting algorithms work, how to determine
the runtime of an algorithm ... you can discuss these items with fellow
classmates and seek assitance from others (as mentioned above you can also
look up these items in a book
or in tutorials and attempt to figure them out - 1) by reading and 2) by
practicing - create a short program to test a sorting algorithm, to test
some namespace issues, to demonstrate a concept in it's most basic form).
Where the gray area begins to "cross over" and become a clear
violation is when you start talking about how to implement the namespace
stuff with respect to the project or how to write the + operator for
the project or ...
And it should be very clear that if in the process of seeking
assistance you show your code to another student or look at the code of
another student's project this has more than "crossed over the line" and
is beyond the gray area and constitutes a violation of the
Honor Code.
Member Initializer Lists (look it up if you've never heard of it before)
are a VERY important concept to understand and know about constructors
and you can't fully complete the project without understanding them.
It turns out that this is possible (using a special const_cast)
HOWEVER you do not have to worry about copying this part of the MyString
on the right hand side (of the = (assignment) operator) into the MyString
object on the left hand side (just copy the string/linked list portion
over).
Also with the operator+ function (which concatenates two MyStrings
together to create a new MyString object) it doesn't matter what
delimiter character the resulting MyString (which is returned) has
(meaning we won't test to see what delimiter it has).
And finally, when comparing two MyStrings (using operator==) do not
worry about checking to see if their delimiter characters match - the
only thing that should be checked is to see if the two MyStrings
contain the same string (case sensitive).
Note: A lot of project #0 uses the concept of operator overloading
which allows someone to modify the built in operators (like + for
example) to work with User Defined Objects (classes).
Doing a Google search on "Operator Overloading C++ Tutorial" results
in a few decent resources. Additionally chapter 8 of the CMSC 114
textbook (C++ How to Program by Deitel & Deitel) is completely
dedicated to covering this topic. And finally, although it isn't
primarily a C++ language reference, the CMSC 214 textbook, in chapter
2 section 4, covers this feature of the C++ language (plus checking
the 214 text index in the back of the book under "Operator" reveals
several other areas in the text that talk about Operator Overloading.
Hopefully most people are familiar with the concept of a stack,
however if you are not the following will help both describe how
a stack works and in particular a "DoubleStack" (which is just a
minor "enhancement" over a basic stack).
One important note: the "push" (operator+) and "pop" (operator--)
functions of the DoubleStack class should NOT perform ANY dynamic
memory allocations or deletions - repeat do NOT delete or create
any dynamic memory in the "push" or "pop" operators.
In general STACKs are implemented using an array of items. Items
can be pushed (aka added) onto the top of a stack and then
popped (aka removed) off of the stack (but only from the top).
In this project a DoubleStack (using the default ctor) starts out
empty HOWEVER has enough space for up to 100 items (the size) and the
data component would look like this (a pointer to a 100 element
array of characters which is initially "empty"):
For example if we push the characters A, ?, and f
onto the "bottom" stack like follows:
Hopefully this gives a better indication of how a stack works
"mechanically". One might then ask what might a stack be useful for?
It turns out that in various areas of Computer Science stacks will
actually be very useful - things like systems programming and
compilers - a hopefully easy example is if you think about how
function calls work and how they might keep track of their variables
and memory (using a slightly more advance stack than that above).
This directory contains a "secondary" test main routine along with the
corresponding input and output. If your code passes the "primary" input
and output (with the primary main.cpp) then it will be able to submit
and is guaranteed at least 50 points or more. If your code passes the
"secondary" (Complete_Test) (along with the primary) then it is
guaranteed at least 90 points or more (up to a maximum of 100).
Hardcoding is when someone puts cout statements in their code to print out
portions of the sample output(s). For example in project #0 if someone had
modified the main.cpp main function to have a print statement such as:
Another small "tip for success" is to develop (write) your code one
piece at a time and thoroughly test each piece as you write it.
Amazingly we see students in office hours who spent hours
writing all of the code and then didn't start testing it until after
they had most of their code written - even the best programmers out
there generally aren't that brave!
You should start with the most essential functions (typically the ctor's
and dtor and a print function) and write those and then test them:
Note that it is ok to TEMPORARILY add extra public member functions
for testing purposes and then later just remember to remove them
before submitting.
When you come to see someone in office hours for help on your project,
you should always bring a current printout of your code and if
possible a printout of the compiler error messages (if there are any) and
if it compiles a printout of the programs output (and the input used to
generate that output). If you want to get the output of the compilers
error messages you will need to redirect error output as follows:
Having the requested information above will assist the instructional staff
in being better able to assist you and others who are waiting to be
assisted. Please also understand that the office hour room is a shared
resource with other classes and we ask that you be respectful of the
room and others using the room.
Another VERY IMPORTANT thing to do prior to going to office hours is
attempt to "debug" your code as much as possible when you have a problem
and that way when you see the TA you can point to the line (or lines) of
code causing the problem (it should typically only be one line) and
explain to them what the problem is and hopefully they will be able to
figure out the problem (and a solution) and explain it to you so that
you can determine how to fix it. When "debugging" code you can either
attempt to use a debugger (see the tutorials in the posting account)
or just use good old fashion debug cout (or cerr) statements:
Unfortunately we can not do this and you will have to start over
from the beginning. The system staff does keep backups in the case
of catastrophic loss, however it is not possible for us to obtain
individual recovery of recently created/deleted files.
The submit program is now up and running. Be certain to make a backup
copy of your files before attempting to submit and then test your
files prior to submitting. Note that the submit program may reject your
submission if it doesn't meet the MRC (minimum running criteria) - if
this occurs you should read the messages the submission program gives
you and then attempt to submit again (after fixing any possible problems
that may have come up). If you continue to encounter difficulty
submitting the project you should attempt to see someone during any of
the posted office hours. Note: do not "hardcode" the output
of a program in order to make it successfully submit (attempt to see
someone in office hours and get assistance if at all possible).
Some are online via the main class webpage and others are in the
class posting accounts in the directory named
Tutorials and Tutorials/Misc - there is information on the make utility
and the tar command as well as a file about namespace issues. Files
posted in the class accounts may not always be available via the web
and unfortunately we are not able to provide them in any other means.
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 Monday, September 15th, 2003. Note:
any project may be turned in late up to 2 days as specified on the
class syllabus. For details regarding the late policy and any
penalties associated with submitting late projects please see the
class syllabus.
0 1 2 3 4 ... 95 96 97 98 99 <--- these are the indexes of the array
data ---> +---+---+---+---+---+---------+---+---+---+---+---+
| | | | | | ... | | | | | |
+---+---+---+---+---+---------+---+---+---+---+---+
^ ^
| |
top1 top2
Items can then be "pushed" onto either the "top" or "bottom" (upper or
lower) stack. Each stack would "grow" from one end of the array in
towards the middle - and the stack is full when they meet (which may be
in the middle or anywhere else within the DoubleStack).
DoubleStack ds;
'A' + ds;
'?' + ds;
ds + '$'; // pushing onto the "top" stack
'f' + ds;
and also push the character $ onto the "top" stack (see the
fourth line above), then the dynamic array pointed to by the ds would
look like this:
0 1 2 3 4 ... 95 96 97 98 99
data ---> +---+---+---+---+---+---------+---+---+---+---+---+
| A | ? | f | | | ... | | | | | $ |
+---+---+---+---+---+---------+---+---+---+---+---+
^ ^
| |
top1 top2
and then if we popped one item off of the "bottom" stack and pushed
two more items on, like this:
--ds; // pops one item off the "bottom" stack and returns a copy of it
'(' + ds;
'0' + ds;
then the contents of the array would look like this (note that for a
temporary period right after the 'f' was "popped" off the stack,
that the character still actually existed in the array and then was
written over when the '(' was pushed onto the stack):
0 1 2 3 4 ... 95 96 97 98 99
data ---> +---+---+---+---+---+---------+---+---+---+---+---+
| A | ? | ( | 0 | | ... | | | | | $ |
+---+---+---+---+---+---------+---+---+---+---+---+
^ ^
| |
top1 top2
cout << "zyxwvutsrq" << endl;
cout << "ABC" << endl;
somewhere in their main program, that would be "hardcoding" an output.
Why would this be done? This is something that any CMSC 106 student
could do - and thus obviously not what is expected of a CMSC 214
student. The main (and perhaps only) reason someone would do this is
to "fool" the submit and grading programs to "believe" that that
portion of the submitted program works - this is what "hardcoding" is
- and it should not be done. If you have further questions regarding
this or any other Academic Integrity matter you should speak with your
instructor during any of their posted office hours.
int main() {
MyString s1( '*' );
cout << "'" << s1 << "'" << endl;
return 0;
}
and then write the next function and test it:
int main() {
string str( "testing" );
HugeInt s1( str );
cout << s1 << endl;
return 0;
}
and then write the next one (say ==) and test it and then move on
from there - testing as you go. This style of writing/testing will
generally save you hours of headaches later on.
% make >& my.comp.errors
and then the text file "my.comp.errors" will contain your compiler errors
(note: if you changed your Unix shell the above may not work).
cout << "GOT THIS FAR" << endl; // very important to use endl;
someFunctionCall();
cout << "DIDN'T GET THIS FAR" << endl; // and cout is recommended over cerr
and if you see the first line get printed but not the second one, then
the problem may lie somewhere in the function call. It is a straight
forward concept, however a number of students have come to office hours
without doing any debugging on their own (either with a debugger or
with cout's).
|
See the class syllabus for policies concerning email Last Modified: Thu Sep 11 12:29:30 EDT 2003 |
|
|
|
|
|