/* Dictionary.h Specification of a Dictionary Class [Taken from requirements found at http://ciips.ee.uwa.edu.au/~morris/clp110/examp_req.html.] Author: J Morris Date Last Modified: 2 October, 1997 */ typedef struct dictionary *Dictionary; Dictionary ConsDictionary( int max_words ); /* Construct a new dictionary. Pre-cond: max_words > 0 Post-cond: returns a newly constructed Dictionary or NULL if insufficient memory */ int DeleteDictionary( Dictionary d ); /* Delete a dictionary. Pre-cond: d is a valid Dictionary Post-cond: space used by d has been freed returns TRUE if no errors, FALSE on error */ int WordCount( Dictionary d ); /* Count words in the dictionary Pre-cond: d is a valid Dictionary Post-cond: returns count of words currently in Dictionary */ int AddTranslation( Dictionary d, char *lang1, char *lang2 ); /* Add a new translation to the dictionary Neither lang1 nor lang2 may be in the dictionary already Pre-cond: d is a valid Dictionary and lang1 != NULL and strlen( lang1 ) > 0 and lang2 != NULL and strlen( lang2 ) > 0 and FindForeign( d, lang1 ) == NULL and FindEnglish( d, lang2 ) == NULL Post-cond: WordCount( d ) = old WordCount( d ) + 1 and strcmp( FindForeign( d, lang1 ), lang2 ) == 0 and strcmp( FindEnglish( d, lang2 ), lang1 ) == 0 */ int ReplaceTranslation( Dictionary d, char *lang1, char *lang2 ); /* Replace an existing translation in the dictionary lang1 must be in the dictionary already lang2 must not be in the dictionary already Pre-cond: d is a valid Dictionary and lang1 != NULL and strlen( lang1 ) > 0 and lang2 != NULL and strlen( lang2 ) > 0 and FindForeign( d, lang1 ) != NULL and FindEnglish( d, lang2 ) == NULL Post-cond: WordCount( d ) = old WordCount( d ) + 1 and strcmp( FindForeign( d, lang1 ), lang2 ) == 0 and strcmp( FindEnglish( d, lang2 ), lang1 ) == 0 */ char *FindForeign( Dictionary d, char *word ); char *FindEnglish( Dictionary d, char *word ); /* Find translations Pre-cond: d is a valid Dictionary word != NULL and strlen( word ) > 0 Post-cond: returns the translation string or NULL if word is not in the dictionary */