Here is the code we wrote today:

public boolean catDog(String str) {
  int i = 0;
  int len = str.length();
  int cat = 0;            //# cats seen
  int dog = 0;            //# dogs seen
  while(i < len-2) {
    String sub = str.substring(i,i+3);
    if(sub.equals("cat")) {
      cat++;
    }
    if(sub.equals("dog")) {
      dog++;
    }
    i++;
  }
  
  return (cat == dog);
}

public int countCode(String str) {
  int i = 0;
  int retVal = 0;  //# of co_e found
  while(i+3 < str.length()) {
    if((str.charAt(i) == 'c') &&
       (str.charAt(i+1) == 'o') &&
       (str.charAt(i+3) == 'e')) {
      retVal++;
    }
    i++;
  }
  return retVal;
}

public boolean xyzThere(String str) {
  int i = 0;
  int len = str.length();
  while(i < len-2) {
    if(str.substring(i,i+3).equals("xyz") //xyz starts at position i
       && ((i == 0) ||                    //and i is the beginning of the string
           (str.charAt(i-1) != '.'))) {   //or position i-1 isn't a period
      return true;
    }
    i++;
  }
  return false;
}