|
C M S C 2 1 4 C o m p u t e r S c i e n c e I I F a l l 2 0 0 2 |
First, make sure you arent switching rows and columns. You need to allocate rows first, then columns second. Also, you need to allocate the columns based on rows.
Template code can cause the executable to become VERY large.
There is a maximum filesize in your class account, to prevent
files from getting too large. To turn this off (temporarily),
type:
However, since large executables cause large core dumps, you
need to remove them before recompiling.
Also, for OLDER projects, go into the directories and remove all
.o and executables. .h and .cpp files don't use much space (unless
you make MANY copies). This will save space for current compiles.
You should remove the contents of the cxx_repository in older projects
as well.
Occasionally, if you abort out of a session, you may get
unusual files with a .nfs (type ls -al to see) at the
beginning. Such files are also very large, and you should be
able to safely delete them.
Finally, compiling with the -g option (necessary for running
the debugger) can be really slow and cause large executables.
So you may want to turn that option off when not debugging.
Yes, but hardcoding is not the way to go here.
Yes. Just append your new documentation to the old documentation.
The answer is surprisingly simple. Once you have
"****sugar**COOKIE**" (where asterisks represent spaces) from the
command, just call split() a second time on this string, and
you will get "sugar", "COOKIE".
We'll generally accept either, but the "official answer" is
that you should follow the spelling, as in the command echo.
For example, if the person says ITEM_INFO "BAGEL", but
"bagel" was read in from the input, print [BAGEL], rather
than [bagel].
No. They are points. Food items have no weight. Only
boxes have weight.
Yes, if you want. The code is in P1/SampleCode from the posting
account.
Yes. Print the information for MOVE first, then print the
"You won", etc. information afterwards. You can assume
at least one box and one target square, and that all boxes will not
appear on their target squares initially.
Empty squares have no food items, players, or boxes.
Print "=" as before. So, there will be no special symbol
if the player is on a target square.
The specs say to print the boxes that "moved", so technically,
boxes that do not move do not get printed.
Yes. The range was meant for 2 or more boxes, but rather
than have a special case for 1 box, you would list the range.
For example, if the player is at (3,0) and the box
is at (3,1), and the box weighs 100, while the player
has strength 50, you would say the boxes between (3,1)
and (3,1) are too heavy to push.
When you are reading in the list of food items, some food items
may appear twice or more. The purpose is for you to use the
update() method in SortedList. New versions of the
food item will have the same name (at least, based on operator==),
but may have different points or coordinates.
For example,
Once the input information is completely read in, each food item's
name will be unique, based on the version of the food item that
appears latest in the input file (thus, if "bagel" shows up twice,
then use the later of the two versions).
There are two ways to handle this. Either write split2()
which behaves like split() except it returns ArrayList.
Or, you can simply leave Tokenizer alone, and have it return
back a vector, then resize the ArrayList and use a for
loop to copy the vector to the ArrayList.
Finally, you are permitted to add a constructor to ArrayList
which takes a vector of the same type as a parameter (i.e.,
vector<Data>), and constructs an ArrayList of the
same size and a copy of the data.
The reason for NOT rewriting split() to return an ArrayList
is so we can retest split() if necessary, while expecting a
vector of strings as a return result.
Look at Project #2 Game Clarifications for the answer to this.
You should have written two classes for the project by P2. If you
wrote two classes in P1, and modified it for P2, then you don't have
to write any additional classes (though obviously, you can write as
many as you want). If you wrote one class for P1 (say, a Board
class), then you need to write a second class for the game in P2.
Nested classes count as classes (some students have nested, say, a
Player class inside a Board class). Nested classes
should still follow the same rules of private data members (using
public methods to access the data members).
As described in the tutorials, the comparators allow you
to sort in the SortedList using other comparisons besides
the built-in comparison operators. Even though ItemComparator
does not fully exploit this feature of SortedList (since it
uses Item's comparison operators), the feature is there
in principle. In the tutorial, there's an example of writing
a StringComparator so you can sort case-insensitively.
You should use the Comparator object to do comparisons
in locate() instead of using the relational operators
(i.e., <, >) to do the comparison.
Finally, the ItemComparator is NOT a template class.
The only template classes you write are: ArrayList
and SortedList (sort214 is a template function).
According to the specs, no. However, we won't have
a checklist item on it. It's your responsibility to be
careful, and TAs are not required to debug projects
using inheritance. You can certainly do the project without
inheritance (though it is nicer). The code shouldn't be
any shorter using inheritance, though it may be more "elegant".
If you want to, that's fine.
That's correct. It's possible for a target square to
contain a food item or a player, in which case, it's listed
under neither categories. (This was an oversight on my part---I
should have created categories for them. However, I'll leave the
output as is).
Yes. I don't care if you add a few more methods to MovieALQueue.
The main idea is to get you used to unit testing.
Yes. In principle, you're supposed to convert all
occurrences of vector with ArrayList. You might
complain "but I have to change so much code!". Changing code
is a fact of life. If you're afraid to change large amounts of
code, then you're afraid of coding.
Secondly, the purpose of a project is not purely to "get the
program to work". If that were the purpose, there would be no
need to use objects, etc. The goal, in this case, is to learn
how to write and use a template class, and to create a rough
approximation of a vector, and what better way to test
it than to use it in situations where vector should
be used?
How does that affect Tokenizer? I would suggest
writing a split2 method that returns an ArrayList<string>
while leaving the rest of the methods in Tokenizer
alone.
Do something like temp++. This will move the pointer,
but otherwise, do nothing with it.
Pointer arithmetic is a topic covered in CMSC 106, so you should
look it up there.
However, for your benefit, there is now a "pointer arithmetic"
tutorial. Go to the main CMSC 214 webpage, and click on the
Tutorial link. It's the last tutorial on the webpage.
Use the one in the specs. The one in the posting account
now matches the specs.
Yes, you can write helper functions (although they will probably be
template functions as well), and no you can't change the parameters
to sort214 (although you can pick whatever parameters you
want for helper functions).
You can always write private helper methods for
any class. You are encouraged to do so, so that you do not
make methods that are too lengthy. Note: the original method
can just be a "bootstrap" method (see the tutorials on recursion
in the Tutorial webpage, which has a link on the main 214 webpage),
without being recursive.
If the outer class is a template class, then nested classes
are also template classes. Thus, Node (and any other
nested classes) have to be templatized.
That's a dummy parameter. Without it, cxx seems to complain
that it isn't a legitimate template function. You actually
use Data to swap. Recall that swapping requires
you to have a temp variable. In this case, that temp variable
has type Data.
The Data * pointer is not used.
You need to cut-n-paste all methods from ItemSortedList
and ItemArrayList to the templatized versions.
There is additional text at the end of the Comparator
background reading in Task 3 in the main specs.
Yes, P2 is due Sunday, October 20, which is one day after the
original due date.
board.resize( numRows );
for ( int i = 0; i < numRows; i++ ) // SHOULD BE numRows, not numCols
board[ i ].resize( numCols ) ;
unlimit filesize
You need to type this whenever you login (unless you know how
to add it to the startup files).
<food>
apple 20 (2,0)
APPLE 30 (3,4)
</food>
You would read in the first line into a SortedList then
the second one would call update(), and the points would
now be 30, and the coordinates would now be (3,4), and
the spelling would now be APPLE.
|
See the class syllabus for policies concerning email Last Modified: Tuesday September 3, 2002 |
|
|
|
|
|