import tools.*;

class Pareo extends Program {
  void run() {
    TextReader postLect= new TextReader("post.dat", ":");
    TextReader matLect= new TextReader("mat.dat", ":");
    TextWriter escr= new TextWriter("post-mat.dat", ":");
    Post post= new Post(postLect);
    Mat mat= new Mat(matLect);
    while (post.ci!=null && mat.ci!=null) {
      int cmp= compare(post.ci, mat.ci);
      if (cmp<0)
        post= new Post(postLect);
      else if (cmp>0)
        mat= new Mat(matLect);
      else {
        PostMat postMat=
          new PostMat(post.ci, post.nombre, mat.ptje);
        postMat.escribir(escr);
        post= new Post(postLect);
        mat= new Mat(matLect);
      }
    }
    escr.close();
    postLect.close();
    postLect.close();
  }
}
