Word.java
contents ::
  App.java
  Insertion.java
  Sort.java
  test1
  test3
  test5
  test7
  Word.java
  another
  newtest

/* James Little 24/4/01
   Good morning and its a marvelously cold night, the temperature is plumitting... good god its cold.
*/

package jlittle_ex8;

public class Word {

    private int charValue=-1;
    private int freq = -1;
    private String code;
    private String realWord;
    private int left = -1;
    private int right = -1;

    public Word(int charValue, int freq){
         this.charValue=charValue;
         this.freq=freq;
    }

    public Word(String realWord, int freq, int left, int right, int charValue){
         this.realWord=realWord;
         this.freq=freq;
         this.left=left;
         this.right=right;
         this.charValue=charValue;
    }

    /*  public void incFreq(){
         freq++;
         }
    */
    public int getLeft(){
         return left;
    }
    

    public int getRight(){
         return right;
    }


    public void assignCode(String code){
         this.code=code;
    }

    public String getCode(){
         return code;
    }

    public int getFreq(){
         return freq;
    }
    
    public String getString(){
         String s;
         if(charValue==13)s=(char)92 + "u000D";
         else if(charValue==32)s=(char)92 + "u0020";
         else if(charValue==10)s=(char)92 + "u000A";
         else if(charValue==9)s=(char)92 + "u0009";
         else if(charValue==11)s=(char)92 + "u000B";
         else s="something went booboo";
         return s;
    }

    public char getChar(){
         return (char)charValue;
    }

    public int getWord(){
         return charValue;
    }

    public void setWord(String newWord){
         this.code=newWord;
    }

    public String getReal(){
         if(realWord!=null) return realWord;
         else if(charValue==13||charValue==32||charValue==10||charValue==9||charValue==11)
             return getString();
         else return ""+getChar();
    }

    public int lexidex(){
         if(charValue>-1){
             return charValue;
         } else return (int)getReal().charAt(0);
    }
}

James Little