Difference between revisions of "ListCities"

From CMSC 420
 
Line 17: Line 17:
 
<code>
 
<code>
 
     <success>
 
     <success>
         <command name="listCities"/>
+
         <command name="listCities" id="3"/>
 
         <parameters>
 
         <parameters>
 
             <sortBy value="name"/>
 
             <sortBy value="name"/>

Latest revision as of 16:15, 30 September 2013

Prints all cities currently present in the dictionary. The order in which the attributes for the <city> tags are listed is unimportant. However, the city tags themselves must be listed in ascending order either by name or by coordinate, as per the sortBy attribute in the listCities command, whose two legal values are name and coordinate. The ordering by name is asciibetical according to the java.lang.String.compareTo() method, and the ordering by coordinate is discussed in the spec. To reiterate, coordinate ordering is done by comparing x values first; for cities with the same x value, one city is less than another city if its y value is less than the other. This command is only successful if there is at least 1 (1 or more) cities in the dictionary.

Parameters[edit]

  • sortBy

Possible <output>[edit]

A <cityList> tag will be contained in output and will contain 1 or more city tags of the form:

    <city name="city1" x="coordx" y="coordy" color="color1" radius="radius1"/>

Possible <error> types[edit]

  • noCitiesToList

<success> Example[edit]

   <success>
       <command name="listCities" id="3"/>
       <parameters>
           <sortBy value="name"/>
       </parameters>
       <output>
           <cityList>
               <city name="Annapolis" x="19" y="20" color="red" radius="40"/>
               <city name="Derwood" x="5" y="5" color="blue" radius="90"/>
           </cityList>
       </output>
   </success>