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 1 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 CLEAR_ALL() is
***** ==> CLEAR_ALL() All structures are cleared.
The sample output should make this clear. 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(not in this part, but it will come up later), it means a floating
point decimal number printed with exactly three digits after the decimal place
(including trailing zeros as necessary).
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.
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 you don't complete a working skiplist you should use a TreeMap here instead to get some credit).
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>:=Delete dot <name>.<nl>
<error>:=<DNE>|<AA>
<AA>:=Error: Dot <name> has already been mapped and cannot be deleted.
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>:=Dot <name> has been added to the map.<nl>
<error>:=<DNE>|<AI>
<AI>:=Error: The specified dot has already been added to the map.
Output summary:
<output>:=<success>|<error>
<success>:=All dots have been added to the map.<nl>
<error>:= Dictionary is empty.<nl>
Output summary:
<output>:=<success>
<success>:=Total count: <int>.<nl>
Output summary:
<output>:=<success>
<success>:=Update complete.
Output summary:
<output>:=<success>|<error>
<success>:=<dotlist>
<error>:= Tree is empty.<nl>
Output summary:
<output>:=<success>
<success>:=Drawing complete.
Output summary:
<output>:=<success>
<success>:=Drawing complete.