|
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 |
Read the FAQ for updates/corrections. Items that have changed from the previous version will be marked in red to make it easier to spot changes.
You are expected to read FAQ on a daily basis.
Get started right away.
The main part that's missing from the project as of today is the files in the posting account, and the rest of the BNF. However, you should be able to start Task 2, with information provided.
Please note that *all* programming projects in this course (including this one) are to be done independently or with the assistance of the instructional staff of this course only.
Please review the policies outlined on the class syllabus concerning the use of class computer accounts and concerning the University's Code of Academic Integrity. The instructors of this course will review the programs submitted by students for potential violations of the Code of Academic Integrity and if it is believed that a violation has occurred it will be referred to the Office of Judicial Programs and the Student Honor Council.
Hardcoding is considered a violation of academic integrity
Debug any code from Project 1, finish the Tokenizer class, and finish the unit testing from Project 1.
Modify Item to handle multi-word item names. Write additional methods for ItemArrayList. In particular, add methods to the iterators to do "pointer arithmetic". Also, write an erase() method.
Remove loops from ItemSortedList and implement using recursion.
You need to templatize ItemArrayList to ArrayList and ItemSortedList to SortedList.
Then, replace all occurrences of ItemArrayList with
ArrayList<Item> and ItemSortedList with
(10/9) SortedList<Item, ItemComparator>
in the classes you wrote for the Sokoban game.
(10/9) ItemComparator is in the posting account. You need
to finish implementing the class.
You will write a method to sort an ArrayList (corrected 10/9). This will mimic the way it's done in the STL. However, it turns out to be easier to write the code using pointers and C arrays first, and then convert that code to iterators.
You may pick whichever sorting algorithm you want. There is a sorting tutorial on the Tutorial webpage. However, you may wish to refer to your textbook for its explanation. Make sure that the code works (test a few examples) if you use the code from the webpage.
Write MovieALQueue.h and MovieALQueue.cpp. Modify MovieQueueUnit.h and MovieQueueUnit.cpp to MovieALQueueUnit.h and MovieALQueueUnit.cpp so it handles an ArrayList of Movies.
You will re-implement the MovieQueue using a ArrayList<Movie>. You may NOT add a pushFront, popFront method, however. Use only the methods that exist in the templatized ArrayList already.
The goal of this is to show you that if the implementation changes, but the methods don't change, then you can test it the same way. Except for the minor changes in class name, the tests you ran in P1 should still work.
operator== and operator!= have been added to the queue, so you may want to add tests for that.
Add new features to the game as described below. The BNF has been posted. Now, just a matter of making sure there are no real problems with it.
This task is due a few days after Project 2. A preliminary description of Project 4 will be posted within a week. You should come up documentation for at least two classes (perhaps more).
The player still moves as usual, but the messages can now be different since more than one box can be moved at a time (or possibly none at all).
Here are the cases:
You should print out the information in the following order.
<out1> := "Player successfully moves " <units> " units "
[ "EAST" | "WEST" | "NORTH" | "SOUTH" ] <endl>
[ "Box is moved from " <coord> " to "
<coord> <endl> ]*
[ "Player picks up [" <name-of-item> "] at "
<coord> <endl> ]*
[ "Box crushed [" <name-of-item> "] at "
<coord> <endl> ]*
"Player is currently at " <coord> <endl>
<name-of-item> := [ <word> | % ]*
As before, there are several reasons this will happen. However, this has been modified from Project 1.
The output is printed in the following order.
<out1a> := "Player ONLY moves " <units> " of " <units> " units "
[ "EAST" | "WEST" | "NORTH" | "SOUTH" ] <endl>
[ <errorA> | <errorB> | <errorC> ]
[ "Box is moved from " <coord> " to " <coord> <endl> ]*
[ "Player picks up [" <name-of-item> "] at " <coord> <endl> ]*
[ "Box crushed [" <name-of-item> "] at " <coord> <endl> ]*
"Player is currently at " <coord> <endl>
<errorA> := "Player is blocked by "
[ "outer wall" | "wall at " <coord> ] <endl>
<errorB> := "Boxes between " <coord> " and " <coord> " weigh too much ("
<udigits> ") for player's strength (" <udigits> ")" <endl>
<errorC> := "Boxes between " <coord> " and " <coord> " is blocked by "
[ "outer wall" | "wall at " <coord> ] <endl> ]
Only one of three error messages is printed.
If the boxes were at (1,0), (3,0), (4,0), and the player moved north 3 units from (5,0), the problem would still exist. The boxes at (3,0), (4,0) could be moved to (2,0), (3,0), but at this point, there are 3 boxes in a row, that exceed the player's strength.
The only modification to SHOW_FOOD is the food items name are now listed as words separated by a single space. In P1, you might write [cookie]. Now, it could be [chocolate CHIP cookie].
Other than that, the format is the same as in P1.
Modify the display in the following way:
<display> := <numbers> [ <line> ]+ <endl> <more>
<numbers> := <digit> [ <blank><digit> ]+ <endl>
<line> := <digit> " " <char> [ <blank> <char> ]+
<endl>
<char> := "." | "=" | "#" | <lower> | <upper> | "+" | "!" | "$" | "*"
The display now has line and row numbers. Here's an example with 12 columns and 2 rows.
0 1 2 3 4 5 6 7 8 9 0 1
0 . . . = . - # # # # # #
1 . . . . + ! $ . . . . .
Print the rightmost digit of the column or row, starting at 0. Thus, when you print 10 and 11, print out 0 and 1.
Print the legend after this as before. However, the legend should include only the items that are on the ground, and not those that sit on boxes. Print uppercase letters if the item sits on a target square in the legend.
This takes two arguments. The item being dropped (which will be in double quotes), and the name of the box to drop it on. There are two error messages. Either the player is not currently carrying the food item, or the box is not near the player. You may assume the player refers to a valid box name.
The BNF for the input is:
<drop-cmmd> := % "DROP" %% <dquote> <name-of-item> <dquote>
%% <box-color> % <endl>
<name-of-item> := <word> [ %% <word> ]*
<box-color> := <word>
Hint: use erase() to remove the item from the player's list.
These are the following output messages. Print exactly one
of them.
<drop-out> := <drop-good> | <drop-noitem> | <drop-nobox>
<drop-good> := " Player successfully dropped [" <item-name>
"] on [" <box-color> "] " <dir8>
" of player at " <coord> <endl>
<dir8> := "NORTH" | "SOUTH" | "EAST" | "WEST" |
"NE" | "NW" | "SE" | "SW"
<drop-noitem> := " DROP ERROR. Player not carrying [" <item-name>
"]" <endl>
<drop-nobox> := " DROP ERROR. Player not adjacent to box ["
<box-color> "]" <endl>
Note: the food item name may contain more than one word, however,
the box name is only a single word.
You should print exactly one message above. If the player is not carrying the item and not adjacent to the box, print that the player is not carrying the item.
<coord> refers to the coordinate of the box that the item was dropped on.
This takes one argument: the name of the item being picked up. This item must be sitting on a box, and be within one square of the current location of the player, otherwise it fails. If successful, the item is no longer on the box.
The BNF for the input is:
<pickup-cmmd> := % "PICKUP" %% <dquote> <item-name> <dquote> % <endl>
These are the following output messages. Print exactly one
of them.
<pickup-out> := <pickup-good> | <pickup-noitem>
<pickup-good> := " Player successfully picked up [" <item-name>
"] on [" <box-color> "] " <dir8>
" of player at " <coord> <endl>
<pickup-noitem> := " PICKUP ERROR. Player not adjacent to item ["
<item-name> "]" <endl>
<coord> refers to the coordinate of the box that the item was picked up from.
Note: player can not pick items up off the floor with this command. Players pick up items implicitly by walking on a square that contains an item (but has no box).
(10/13) pickup-nobox BNF has been removed. The message for pickup-noitem is printed when a player is not adjacent to a BOX with the food item on top. So, even if a player is adjacent to a food item, but the food item is NOT on a box, you still print the pickup-noitem. A better error message would be nice, but this allows the BNF to stay as is.
This takes one argument: the color of the box. This prints out the coordinate of the box, any items on the box, and if the box is lying on a target square.
The input BNF:
<boxinfo-cmmd> := % "BOX_INFO" %% <box-color> % <endl>
You may assume the color is valid.
The output BNF is:
(SEE REVISED BNF below)
<boxinfo-out> := " The [" <box-color> "] box is at " <coord> <endl>
<show-food>
" The [" <box-color> "] box " [ "IS" | "IS NOT" ]
" on a target square" <endl>
" The [" <box-color> "] box weighs "
<udigits> " units" <endl>
The food items on the box should be listed in the order that it was placed on the box. Notice the syntax is the same as for SHOW_FOOD, except it displays the food items on the box.
(10/13) When there is no food items on the box,
print
<no-food-box> := " [" <box-color> "] box has no food items on it" <endl>
since the error message used in <show-food> makes
no sense for boxes without food items (makes sense for players).
<boxinfo-out> := " The [" <box-color> "] box is at " <coord> <endl>
<boxinfo-show-food>
" The [" <box-color> "] box " [ "IS" | "IS NOT" ]
" on a target square" <endl>
" The [" <box-color> "] box weighs "
<udigits> " units" <endl>
<boxinfo-show-food> := Food items" <endl>
"----*----*" <endl>
[ <food-list> | <no-food-box> ]
<endl>
<boxtotal-points>
<no-food-box> := " [" <box-color> "] box has no food items on it" <endl>
<food-items> := [ <food> ]+
<food> := "(" <udigits> ") [" <name-of-item> "]" <udigits> " pts" <endl>
<boxtotal-points> := "The box holds (" <udigits> ") total pts" <endl>
The input BNF:
<boxinfosort-cmmd> := % "BOX_INFO_SORTED" %% <box-color> % <endl>
The output is similar, except <show-food> prints the items in sorted order. You should use sort214 to sort the items. However, you should realize a person can still call BOX_INFO afterwards and access the items in the order placed on the box.
(10/13) See message above for what happens when box has no food items on it
(10/17) Look at the revised BNF above.
This indicates how many boxes lie on target squares, and which target squares are empty. This method takes no arguments.
The input BNF:
<targetinfo-cmmd> := % "TARGET_INFO" % <endl>
The output BNF is:
<targetinfo-out> := "BOXES ON TARGET" <endl>
"----*----*----*" <endl>
[ <target-list> | <empty-target-list> ]
<endl>
"EMPTY TARGET SQUARES" <endl>
"----*----*----*----*" <endl>
[ " " <coord> <endl> ]+
<empty-target-list> := " No boxes lie on target squares" <endl>
<target-list> := [ " " <box-color> " " <coord> <endl> ]+
(10/13) Print the boxes in row major order. That is, the boxes should be printed by writing a nested loop where the outer variable is the row, and the inner loop is the column, and printing the coordinates of target squares, in the order visited by the loop. For example, if the target squares are at (0,0), (1,1), (1,3), (2,4), you would print it out in that order, since these are the target squares that would be visited in row-major order.
This indicates where an item is on the board. It may be on a square, on a box, on the player, or crushed. You may assume a valid item name.
The input BNF:
<iteminfo-cmmd> := % "ITEM_INFO" %% <food-name> % <endl>
<food-name> := <dquote> % <word> [ %% <word> ]* % <dquote>
You may assume a valid item name. Notice the food item name is
in double quotes since it can contain more than one word.
<iteminfo-out> := <item-player> | <item-square> | <item-target> | <item-box> | <item-crushed>
<item-player> := " Player is carrying [" <item-name> "]" <endl>
<item-square> := " [" <item-name> "] is at "
<coord> <endl>
<item-target> := " [" <item-name> "] is on target square at "
<coord> <endl>
<item-box> := " [" <item-name> "] is on a box at "
<coord> [ " which is on a target square" ]?
<endl>
<item-crushed> := " [" <item-name> "] has been crushed" <endl>
The messages are:
If a command does not fall in any category above (or from P1), then it is an invalid command. An invalid command has the following input BNF.
<invalid-cmmd> := % <invalid-word> [ %% <word> ]* % <endl>
<invalid-word> := <word>
That is, it is the name of the invalid command (a single word), possibly
followed by other words on the same line.
Print the following message:
<invalid-out> := " [" <invalid-word> "] is an INVALID command" <endl>
The remaining words on the lines should be ignored, and processing
begins on the next valid line of command input.
<all> := <dim> <boxes> <target-squares> <walls> <food-list> <player> <cmmds>
<dim> := % "<size>" % <endl>
% <udigits> %% <udigits> %
% "</size>" % <endl>
<boxes> := % "<box>" % <endl>
[ % <one-box> [ %% <one-box> ]* % <endl> ]*
% "</box>" % <endl>
<one-box> := <coord> %% <box-color> %% <weight>
<weight> := <udigits>
<target-squares> := % "<target>" % <endl>
[ % <coord> [ %% <coord> ]* % <endl> ]*
% "</target>" % <endl>
<walls> := % "<wall>" % <endl>
[ % <coord> [ %% <coord> ]* % <endl> ]*
% "</wall>" % <endl>
<food-list> := % "<food>" % <endl>
[ % <one-food-item> ]*
% "</food>" % <endl>
<one-food-item> := % <food-name> %% <points> %% <coord> % <endl>
<food-name> := <dquote> % <word> [ %% <word> ]* % <dquote>
<points> := <udigits>
<player> := % "<player>" % <endl>
% <coord> %% <strength> % <endl>
% "</player>" % <endl>
<strength> := <udigits>
<cmmds> := % "<command>" % <endl>
[ % "MOVE" %% <dir> %% <udigits> % <endl> |
% "DISPLAY" % <endl> |
% "DISPLAY_BACKWARD" % <endl> |
% "SHOW_FOOD" % <endl> |
% "DROP" %% <food-name>
%% <box-color> % <endl> |
% "PICKUP" %% <food-name> % <endl> |
% "BOX_INFO" %% <box-color> % <endl> |
% "BOX_INFO_SORTED" %% <box-color> % <endl> |
% "TARGET_INFO" % <endl> |
% "ITEM_INFO" %% <food-name> % <endl> |
% "QUIT" % <endl> |
<invalid-cmmd> ]*
% "</command>" % <endl>
For each of the REQ, put a comment in the code and/or header file where you have met these requirements. For example, you would write // REQ2-3. This way, the graders can easily find where you have met the requirements. If these are missing, we may deduct points, even if you have met the requirements.
Here are some requirements/restrictions:
At the top of the file, after your name, etc. Explain why you felt you needed this class.
You may feel free to use whatever string methods or vector methods you can find in the book, etc., unless it is not in the spirit of the project (e.g., don't use vectors, when you are asked to use a SortedList).
Therefore, you should NOT ASSUME that submitting successfully means you have passed primary input.
To best ensure that you HAVE passed primary, you should test your TAR file before submission. This means the following:
Failing to follow these procedures may result in a project that "submits" (due to some glitch), but may not actually pass primary input.
In order to successfully submit your project, it must pass
the primary input and produce the primary output. The primary
input will be sent to your project using input redirection.
p2 < primary.input
Your program MUST produce the executable p2, EXACTLY, when
the command "make" is run with "p2" as argument. Thus, you must use
a makefile named exactly "Makefile".
Your makefile must generate .o files , and you must not #include .cpp files (unless used for templates). You must link .o files to create your executable. You must also use macros in your makefile. Suffix rules are permitted.
We will use "diff -bwi" to test your code. This ignores case, treats N blanks as 1 blank, treats N blank lines as 1 blank line. We will also strip all blank lines from your input when matching to ours. However, diff is sensitive to punctuation, number of dashes, etc. so you should attempt to make your output match ours as closely as possible otherwise you may not be able to submit your program. If this is the case (that your program does not submit) you must fix your code until the output it produces matches that of the primary output. Note: "hardcoding" output is a violation of the University's Code of Academic Integrity.
To submit your project you must first combine the following files (and only these files) into a single tar file using the Unix tar command:
You may name your tarfile anything you want, but p2.tar is the suggested name.
NOTE! You should make a backup copy of all your files BEFORE attempting to create your tarfile!!!! You have been warned.
After creating the tar file you should submit that one file using
the following command:
submit p2.tar 2
where p2.tar can be replaced by whichever tar file you
have created, and 2 refers to the current project,
|
See the class syllabus for policies concerning email Last Modified: Tue Feb 12 19:48:57 EST 2002 |
|
|
|
|
|