1 / 3

Ejemplos: * leer una agenda de un fichero * escribir una agenda en un fichero

Ejemplos: * leer una agenda de un fichero * escribir una agenda en un fichero * comparar dos agendas * comparar dos items. public agenda ( input fich ) { numElem = 0 ; listaItems = new itemAgenda [ MaxItem ]; String linea ; itemAgenda item ;

lavada
Download Presentation

Ejemplos: * leer una agenda de un fichero * escribir una agenda en un fichero

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ejemplos: * leer una agenda de un fichero * escribir una agenda en un fichero * comparar dos agendas * comparar dos items public agenda(input fich) { numElem=0; listaItems=new itemAgenda [MaxItem]; Stringlinea;itemAgendaitem; while(fich.more()) { linea=fich.readline(); int indice = linea.indexOf("telefono: "); Stringnom=linea.substring(8, indice-5); Stringtfno=linea.substring(indice+10, linea.length()); item=new itemAgenda(tfno, nom); anyadirItem(item); } } public agenda() { numElem=0; listaItems=new itemAgenda [MaxItem]} nombre: Manoli --> telefono: 963000001 nombre: David --> telefono: 963000002 nombre: Siona --> telefono: 963000003 nombre: Jose Luis --> telefono: 963000004° 8car. 5 10car.

  2. Ejemplos: * leer una agenda de un fichero * escribir una agenda en un fichero * comparar dos agendas * comparar dos items public voiddescargaAgenda(output fich) { Stringtexto= this.toString(); fich.write(texto); }

  3. Ejemplos: * leer una agenda de un fichero * escribir una agenda en un fichero * comparar dos agendas * comparar dos items public booleanequals(agenda a) { // búsquedadelitem donde difieren booleaniguales= false ; // itemb ==null if (numElem== a.numElem) { int i = 0; while (i<numElem && listaItems[i].equals(a.listaItems[i]))) i++; if (i< numElem) iguales= true; // sino iguales ==false } return (iguales) ; } public boolean equals(itemAgendaitem) { return (nombre.equals(item.nombre) && telefono.equals(item.telefono) ) ; }

More Related