class Dicc56 extends Program {
  String[] pals;
  String[] defs;
  int npal;
  int maxpal;
  // Constructor
  Dicc56(int maxpal) {
    this.maxpal= maxpal;
    pals= new String[maxpal];
    defs= new String[maxpal]; 
    npal= 0;
  }
  void definir(String pal, String def) {
    int i= 0;
    while (i<npal) {
      if (compare(pals[i], pal)==0)
        break;
      i= i+1;
    }
    if (i<npal)
      defs[i]= def; // Es una redefinicion
    else if (i<maxpal) {
      defs[i]= def; // Es una nueva definicion
      pals[i]= pal;
      npal= npal+1;
    }
  }
  String consultar(String pal) {
    int i= 0;
    while (i<npal) {
      if (compare(pals[i], pal)==0)
        return defs[i];
      i= i+1;
    }
    return "no definida";
  }
  int apropos(String str, String[] arreglo, int n) {
    int i= 0;
    int cont= 0;
    while (cont<n && i<npal) {
      if (indexOf(defs[i], str)!=-1) {
        arreglo[cont]= pals[i];
        cont= cont+1;
      }
      i= i+1;
    }
    return cont;
  }
}
