You will build a command decoder with a small set of commands; you will expand it later to accommodate commands required for future parts.
The following is a list of commands you should support for part 2 and a description of
the output you should give for each one. Note that for all functions, you should
print ''*****\n'' followed by a '' ==> `` and an echo of the command given.
For instance, the entire valid output to a hypothtical *wink wink* CLEAR_ALL() command
would be:
***** ==> CLEAR_ALL() All structures are cleared.
This is done to negate the effects of input redirection and to assist in grading. Note that although it is done in the samples that will appear later, you are not required to reformat the original command (fixing spacing, for instance) in any way.
The definitions below will use the following standard BNF definitions.
<dotlist>:=<dot><nl><dotlist>|<dot><nl>
<dot>:= <name> at (<int>,<int>) color:<color>
<color>:= RED|GREEN|BLUE|BLACK|WHITE
<DNE>:=Error: The specified dot does not exist.<nl>
Whenever a <double> appears, it means a floating
point decimal number printed with
exactly three digits after the decimal place
(including trailing zeros as necessary). To do this in java check out the NumberFormat class.
Also, when looking at the list of errors, eg.
<error>:= <DNE>|<NR>|<AI>|<DC>|<NZ>
the leftmost applicable error should always be the one printed.
Output summary:
<output>:=<success>|<error>
<success>:=Quadtree initialized.<nl>
<error>:=<OOR>|<INIT>
<OOR>:=Error: size out of range.<nl>
<INIT>:=Error: The Quadtree has already been initialized.<nl>
Coordinates will be non-negative. This should be an O(logn) operation where n is the number of dots already in the dictionary. The dots should be stored in an asciibetically sorted SkipList.
If a dot with the same name already exists print an error. If a dock already exists at the specified coordinates print an error.
Output summary:
<output>:=<success>|<error>
<success>:=Created dot <dot>.<nl>
<error>:=<AE>|<DC>
<AE>:=Error: Dot <name> already exists.<nl>
<DC>:=Error: Dot <other\_dot\_name> already exists at the specified coordinates.
***
Output summary:
<output>:=<success>|<error>
<success>:=Deleted dot <name>.<nl>
<error>:=<DNE>|<AA>|<ZZ>
<AA>:=Error: Dot <name> has already been added to the Adjacency List.
<ZZ>:=Error: Dot <name> has already been added to the Quadtree.
Output summary:
<output>:=<success>|<error>
<success>:=<dotlist>
<error>:= Dictionary is empty.<nl>
Output summary:
<output>:=<success>|<error>
<success>:=Color of <name> changed from <oldcolor> to <color>.<nl>
<error>:=<DNE>
Output summary:
<output>:=<success>|<error>
<success>:=Created segment (name1,name2).<nl>
<error>:=<DNE>|<AI>
<AI>:=Error: The specified segment already exists.
Output summary:
<output>:=<success>|<error>
<success>:=Deleted Segment (name1,name2).<nl>
<error>:=<DNE>|<SDNE>|<AM>
<SDNE>:=Error: The specified segment does not exist.
Output summary:
<output>:=<success>|<error>
<success>:= <name1> -> <moredots> <nl>Total length:<double>.<nl>
<moredots>:= <dotname> -> <moredots>| <name2>
<error>:= <DNE>|<NP>
<NP>:= Error: No path exists.
Output summary:
<output>:=<success>|<error>
<success>:=Mapped segment (name1,name2).<nl>
<error>:=<DNE>|<ID>
<ID>:=Error: Intersection detected.
Output summary:
<output>:=<success>|<error>
<success>:=Unmapped Segment (name1,name2).<nl>
<error>:=<DNE>|<SNF>
<SNF>:=Error: The specified segment was not found on the map.
Output summary:
<output>:=<success>
<success>:=Update complete. Found <int> segments.
A:A
IE., a one element tree should look like a leaf, even if not implemented that way.
Output summary:
<output>:=<success>|<error>
<success>:= <pmtree><nl>
<pmtree>:=<black_node><nl>|<white_node><nl>|<nl><grey_node>
<grey_node>:= NW <pmtree> NE <pmtree> SW <pmtree> SE <pmtree>
<black_node>:=<name>:<namelist>|<segment><nl>
<white_node>:=
<namelist>:= <name><namelist>|<name>
<segment>:= (<name1>,<name2>)
<error>:= Tree is empty.<nl>
Output summary:
<output>:=<success>
<success>:=Drawing complete.
Output summary:
<output>:=<success>
<success>:=Drawing complete.