next up previous
Next: Preview: Part 3 and Part 4 Up: Part 2: Robust Site Previous: BNF Conventions

Commands

INIT_BPTREE(order)
This command takes one parameter: the order of the B+ tree to be created, which is an integer that is greater than or equal to three (3). All B+ trees that are created during a given execution of your code must have this order. If the B+ tree order has not been initialized, this command will initialize the B+ trees to have the specified order and print the <success> message. If the B+ tree order has already been initialized, then you should print the <error> message.

Note: Even if you don't implement the B+ tree, and must submit using the treemap from Part 1, you must still implement this function, printing the appropriate <success> message. Because this is always the first command and diff is used in grading, if you skip this function your project will fail every test!

Output summary:
<output>:=<success>|<error>
<success>:=Initialized B+ trees to order <order>.<nl>
<error>:=<BPTreesAlreadyInitialized>|<InvalidBPTreeOrder>

EXIT()
This is the simplest command. It should end the program. Your program should also naturally terminate (with no exit message) when the end-of-file is reached. Print a goodbye message and exit the program.

Output summary:
<output>:=mission complete<nl>

CLEAR_ALL()
This command takes no parameters. This command should delete all entries from the dictionary, spatial data structure, and inventory heap. (Hint: You don't actually have to perform any delete operations on any of these objects.) A confirmation message should be printed.

Output summary:
<output>:=sites cleared<nl>

CREATE_FRIENDLY_SITE(name, latitude, longitude)
This command takes three parameters: the name of the site as a case insensitive SiteType encoded string; the latitude as an integer; and the longitude as an integer. Both latitude and longitude should be integers in the range [0, 1024). Your Mediator should parse this information and store it in a friendly object in your Friendly Object Data Dictionary. If the dictionary does not already contain a friendly object by the same name, you should add the base to the dictionary And spatial structure then print the <success> message. If there is a object in the dictionary with the same name, you should print the <SiteAlreadyExists> error message. Duplicate data can exist between the seperate data dictionarys. For example, you can have a "Gerogia" base in your friendly data dictionary and a "Gerogia" base in your enemy data dictionary. Note that the sorted object order is asciibetically by their case insensitive name. This should be an O(log n) operation if you have implemented your data dictionary correctly.

Output summary:
<output>:= <success>|<error>
<success>:=created friendly site <Site>.<nl>
<error>:=<SiteAlreadyExists>

CREATE_ENEMY_SITE(name, latitude, longitude)
This command takes three parameters: the name of the site as a case insensitive SiteType encoded string; the latitude as an integer; and the longitude as an integer. Both latitude and longitude should be integers in the range [0, 1024). Your Mediator should parse this information and store it in a enemy object in your Enemy Object Data Dictionary. If the dictionary does not already contain a friendly object by the same name, you should add the base to the dictionary And spatial structure then print the <success> message. If there is a object in the dictionary with the same name, you should print the <SiteAlreadyExists> error message. Duplicate data can exist between the separate data dictionarys. For example, you can have an "Alexandria'' Air unit in both your Friendly and Enemy data dictionaries. Note that the sorted object order is asciibetically by their case insensitive name. This should be an O(log n) operation if you have implemented your data dictionary correctly.

Output summary:
<output>:= <success>|<error>
<success>:=created enemy site <Site>.<nl>
<error>:=<SiteAlreadyExists>

DELETE_SITE(name)
The delete site command will not be supported in Part 2. Any attempt to use DELETE_SITE or DELETE_DATA in Part  2 should result in the <InvalidCommand> error message.

LIST_SITES(dictionaryType)
This command takes one parameter: a dictionaryType, "F" for Friendly, "E" for Enemy, that denotes the data dictionary to be printed. This command should print out a list of all of the sites in the data dictionary, indicated by the site type, in asciibetically sorted order. If the dictionary is empty, print the
<NoSitesEntered> message. If there are sites in the dictionary, print them as described below. Note that site names are case insensitive so if the name of one site was "baltimore" and another site was named "Reno" then "Reno" would be printed before "baltimore" (since "R" comes before "b" in the ASCII character set).

Dictionary Types:
F - Friendly
E - Enemy

Output summary:
<output>:=<SiteList>|<NoSitesEntered>
<SiteList>:=<Site><nl><SiteList>|<Site><nl>
<NoSitesEntered>:=No sites have been entered into the dictionary.<nl>

PRINT_BPTREE(type)
The purpose of this command is to print out the structure of the B+ tree using as a data dictionary by doing a breadth first search. However, if you used links between internal nodes you can produce the same results as BFS with much cleaner code. The parameter $type$ determines which data dictionary is to be printed, where ``F'' indicates Friendly and ``E'' indicates Enemy.

The output is formatted so that each level of the tree is enclosed in braces {}; each node is enclosed in parentheses; guide values in each internal node are separated by commas; key values within leaf nodes are separated commas. Each level of the tree should appear on its own line and in order. Thus, a tree of order three (3) with five keys (names of sites) might look like this:

{(Bowie)}
{(Baltimore) (CollegePark)}
{(Annapolis,Baltimore) (Bowie) (CollegePark, HolyCross)}

Note that by convention, the leaf containing the key ``CollegePark'' (the key of the object of type ``civilian territory'' with site name ``CollegePark'') is a right child of the internal node containing the guide value ``CollegePark''. That is, we have a rule for dealing with equal guide and key values.

Even at the leaves print only the key (the site name). If the data dictionary is empty, print the <NoSitesEntered> message. Your tree is not expected to match ours exactly. Your grade will be based on your tree displaying the properties described above in the INIT_BPTREE command.

For our order m tree: The leaves contain between 1 and m-1 keys, inclusive. They may not have m keys. Internal node must have between ceiling(m/2) and m children, inclusive. For each internal node, the number of guide values printed must be one less than number of child nodes, meaning that (no 'extra' key on the far left should be printed, even if you used one in your implementation. Your tree, of course, must also contain the correct data at the leaves!

Output summary:
<output>:=<success>|<error>

<success>:=<b+rows><nl>
<b+rows>:=<b+row><nl><b+rows>|<b+row>
<b+row>:={<nodes>}
<nodes>:=<node>,<nodes>|<node>
<node>:=(<keys>)
<keys>:=<key>,<keys>|<key>
<key>:=<SiteName>

<error>:=<NoSitesEntered>

MAP_SITE(name, dictionaryType)
This command takes two parameters: the name of the site to map as a case insensitive string and the dictionaryType( Friendly or Enemy) as character. You should search the dictionary for the site. If the dictionaryType equals "F'' then you are searching for a Friendly site, and ``E" if you are searching for an Enemy site. If the site exists in the dictionary and there is no site mapped to the same coordinates, map it by adding it to the spatial data structure and print the <success> message. Note, there is only one spatial data structure for both friendly and enemy sites. If the site could not be found, print the <SiteDoesNotExist> error message. If the site was found but a site was already mapped to the same coordinates (either the same site or a site with a different name but the same coordinates), print the <SiteAlreadyMapped> error message using the site which is already mapped in the spatial data structure. Please note that this may or may not be the same site that was specified as a parameter. For instance, if the site "Buda at (600,600)" is already in the map and we attempted to map "Pest at (600,600)" then we would get the error message "Error: The site Buda at (600,600) has already been mapped at those coordinates."

Recall that both latitude and longitude are integers in the range [0, 1024). This should be an O(log n) operation.

Dictionary Types:
F - Friendly
E - Enemy

Output summary:
<output>:=<success>|<error>
<success>:=Mapped site <Site>.<nl>
<error>:=<SiteDoesNotExist>|<SiteAlreadyMapped>

UNMAP_SITE(name, dictionaryType)
Note: Replaces CLEAR_COORDINATE(longitude,latitude) from Part 1. This commands takes two parameters: the name of a site as a case insensitive string and the dictionaryType as an character 'F' or 'E'. You should search the data dictionary for the site. If it is not found, print the <SiteDoesNotExist> error message. If the site does exist, you should search the spatial data structure for a site with the specified name. If the site cannot be found in the spatial data structure because it was not mapped, print the <SiteNotMapped> error message. If the site has been mapped, then delete the site from the map/spatial data structure and print the <success> message. This should be an O(log n) operation.

Dictionary Types:
F - Friendly
E - Enemy

Output summary:
<output>:=<success>|<error>
<success>:=Unmapped site <site>.<nl>
<error>:=<SiteDoesNotExist>|<SiteNotMapped>

PRINT_MAP()
Note, this command takes the place of PRINT_SPATIAL This command takes no parameters. This command prints the spatial data structure (in Part 2, a PR quadtree) in the order (NW, NE, SW, SE). Before going in any direction you should print out the direction you are about to go. Only one direction should appear on a line. You should also indent two (2) spaces for each level of depth in the tree. The site name itself should be printed on the same line as the last direction printed. For instance, a tree containing (Baltimore,0,1000), and (HolyCross,1000,0) would print as:

          NW military base: Baltimore at (0,1000)
          NE
          SW
          SE hospital: HolyCross is at (1000,0)

If the military base (Bowie,500,600) were added, the output would look like:

          NW 
            NW military base: Baltimore at (0,1000)
            NE
            SW
            SE military base: Bowie at (500,600)
          NE
          SW
          SE hospital: HolyCross at (1000,0)

Output summary:
<output>:=<success>|<error>
<success>:= <grey_node><nl>
<prtree>:=<black_node><nl>|<white_node><nl>|<nl><grey_node>
<grey_node>:= NW <prtree> NE <prtree> SW <prtree> SE <prtree>
<black_node>:=<Site><nl>
<white_node>:=
<error>:= No matching sites found.<nl>

DRAW_MAP()
This command takes no parameters. This command will draw a graphical map by examining the quadtree and drawing the partitions, the points in the quadtree, and all of the roads that are in the adjacency list and print the <success> message. Although you are welcome to make use of any drawing mechanisms in JAVA, we recommend that you use the CanvasPlus drawing package on the class web page which was written specifically to support this feature.

Please use common sense in rendering your picture to a size that fits on an average size screen(1024x768 max). It is understood the small quadrants will be difficult to see in the picture, this is ok. We will only be eye-balling your drawing during grading; so, as long as you have a picture that represents the mapped cities and the roads somewhat correctly we'll be happy.

Note that this function is primarily to help *you* debug your code. It will be very helpful in Part 2 to help you determine if your UNMAP_SITE function is working correctly and it will become an invaluable debugging tool for your PM1 quadtree in Parts 3 and 4.

Output summary:
<output>:=<success>
<success>:=Drawing complete.<nl>


next up previous
Next: Preview: Part 3 and Part 4 Up: Part 2: Robust Site Previous: BNF Conventions
MM Hugue 2004-02-28

Web Accessibility