next up previous
Next: Submission Instructions Up: Part 2: SkipList and Previous: SkipList.java


Part 2 Command Specification

You will build a command decoder with a small set of commands(you may of course use the framework provided by the TA); 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 EXIT() is
*****
==> EXIT()
Have a nice day!
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> 

          <framelist>:<frame>|<frame><framelist>
          <frame>:Frame <int><nl><dotlist>
The <int> in a frame is the 0 based frame number for the current drawing command. For instance, if you are drawing the 300th frame of ANIMATE_HORIZONTAL_PATH, then the int should be 299. The points should be printed as they appear in the ordering where $P1<P2$ if P1.x < P2.x or P1.x==P2.x and P1.x<P1.y$\\
$P1>P2 $ if P1.x > P2.x or P1.x==P2.x and P1.x>P1.y$
$P1==P2 otherwise$ 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.
EXIT()
ends the program. Your program shoudl also naturally terminate (with no exit message) when end-of-file is reached. Print a goodbye message (as specified below) and exit the command interpreter.
          Output summary:
          <success>:=Have a nice day!
CREATE_DOT(name, x, y, radius, color)
creates a 'dot' object with the appropriate name, coordinates, radius, and color. The dot will then be added to a SkipList sorted based on the name (the data dictionary) and to one based on the coordinates. The latter structure is used to check for duplicate coordinates. 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 SortedMap(SkipList for project 2). If a dot with the same name already exists print an error. If a dot 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.
DELETE_DOT(name)
Removes the dot with the given name from the data dictionary(and the coordinate checking dictionary). If the dot does not exist print an error. Delete should be O(logn).
          Output summary:
          <output>:=<success>|<error>
          <success>:=Deleted dot <name>.<nl>
         
          <error>:=<DNE>
LIST_DOTS()
Lists all dots in the data dictionary in increasing asciibetical order. This function will be used as a measure of success for the CREATE_DOT function. (Hint: You should probably be using SortedMap.values().iterator() to implement this;)
          Output summary:
          <output>:=<success>|<error>

          <success>:=<dotlist>
          <error>:= Dictionary is empty.<nl>
COLOR_DOT(name,color)
Changes the color of the dot with the specified name to the color given. The change should be reflected in the map, however the kd tree itself should not be accessed for this operation.
          Output summary:
          <output>:=<success>|<error>
          <success>:=Color of <name> changed from <oldcolor> to <color>.<nl>
         
          <error>:=<DNE>
SET_DRAW_MODE(mode, xsize, ysize, step)
Changes the mode for all graphical output commands. The mode will be either "TEXT", "DRAW", or "BOTH". If BOTH, then you should print text before drawing to the screen. "TEXT" will be the mode used when grading, the others will mostly be for your benefit in debugging and for impressing your friends. If the input is invalid (I will not test this) stay in the current mode. To be safe I will always call this function before using a drawing command, so you may use whatever default you find handiest. xsize and ysize will specify the size of the view window used on the map. When drawing a frame the current coordinate should be treated as the center of the view window, with xsize units above and below the center and ysize units to the left and right, so that the actual window is 2*xsize by 2*ysize. The step is only used for animation commands and says how far to move each frame in the current direction of travel(always east/right now). If you are following a particular line and the next step will cause you to pass the end of that line then you should have a frame exactly at that endpoint instead.
DRAW_FRAME(xpos,ypos)
Processes the first frame only of the ANIMATE_HORIZONTAL_PATH command, centered at (xpos,ypos).
          Output summary:
          <output>:=<optional textoutput><nl><success>
          <success>:=Draw Frame Complete.<nl>
          <optional textoutput>:=<frame>
ANIMATE_HORIZONTAL_PATH(xmin,xmax,ypos)
The first frame should be centered at (xmin,ypos), and then you should procede right moving 'step' units each frame (as defined SET_DRAW_MODE) till reaching a frame centered at (xmax, ypos). There is no such thing as failure, and there are no bounding requirements for xmin,xmax, and ypos (well, they will be non negative). If the current mode is BOTH or TEXT then each frame should also have a textual version printed according to the BNF.

 
          For efficiency you should use a range search in your coordinate based skiplist (the coordinate
          checking structure for CREATE_DOT).  If it is assumed that all y coordinates are in bounds
          for every frame, then the running for drawing an individual frame
          should be O(logn +k) where k is the number of elements in the frame, and the entire
          animation should be O(logn +m) where m is the total number of points drawn in every 
          frame(points will be counted once for each frame they appear in).
          (ie. you need to do a single lookup to get an iterator at xmin-xsize, 
          and then iterate to
          xmax+xsize.  The way you'd do this with a TreeSet is to use a subSet().iterator(), but you
          may accomplish in other ways (for instance, by implementing an iterator that knows how to seek() 
          in logn time)).

          Output summary:
          <output>:=<optional textoutput><nl><success>
          <success>:=Animation Complete.<nl>
          <optional textoutput>:=<framelist>

next up previous
Next: Submission Instructions Up: Part 2: SkipList and Previous: SkipList.java
MM Hugue 2004-06-02

Web Accessibility