CS1 Course Site

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

 
CS1 Course Site  
 
 
 
Wait , WAIT !!What's that word ? ( Class Notes ( without definitions ) )

Monday November 13 , 2000
 
Specification of the word class
  1. new Word () -- > < word >
    create a word by reading information from the standard input screen.
  2. < word > .length () -- > < int >
    return the length of the word.
  3. < word > .display ();
    Display the ``properties'' of the word.
    Ex
    w -- > word -- > ``monday'' syllables -- > ``| mon | day |''
    w.display ()
    word:   monday
    syllables:   mon | day
  4. < word > .print ()
    print the word
    w.print ();
    monday

  5. Word.equals (< word >,  < word >) -- > < boolean >
  6. Word.less (< word >,  < word >) -- > < boolean >
    returns true if the first word is less than the second one;  false if not.
  7. word.greater (< word >,  < word >) -- > < boolean >

Specifications of the Dictionary class
  1. new Dictionary () -- > < dictionary >
    create s an empty dictionary of words.
  2. < dictionary > .add (< word >)
    add the word to the dictionary
  3. < dictionary > .add (< string >) interpret the string as the name of a data file.
    at the beginning of the file is a number indicating how many words are represented in the file.   This number of words will then be read,  created,  and added to the dictionary
    Ex
    To change a dictionary by reading these files...
    Dictionary lexicon = new Dictionary ();
    lexicon.add ( ``nouns.text'');
    lexicon.add ( ``verbs.text'');
    lexicon.add ( ``adjectives.text'');

  4. < dictionary > .display ()
  5. < dictionary > .size () -- > < int >
  6. < dictionary > .search (< word >) -- > < boolean >
  7. < dictionary > .search (< string >) -- > < int >
    returns the word corrisponding to the string - or ``null'' if no such word exists.
  8. < dictionary > .sort ()
    Order the words alphabetically,  implimenting...
    Word.eaquals (< word >,  < word >) -- > < boolean >
  9. < Word > .word () -- > < string >
  10. < Word > .syllables () -- > < String [] >
static public boolean equals (Word w1,  Word w2)
{
    w1 -- > word:   ---- syllables:   ----
    w2 -- > word:   ----- syllables:   -----
    String w1Word = w1.word ();
    String w2Word = w2.word ();
    boolean result = w1Word.equals (w2Word);
    return result;
}
Implimentation
public string word ()
{
    return word;
}
public String [] syllables ()
{
    return syllables;
}