id
stringlengths
36
36
text
stringlengths
1
1.25M
6ba8a323-bcb5-43c2-bc33-2e47a0dd59c0
public ArrayList<String> getEmail() { return this.email; }
74c9fc13-69b2-4be7-888e-0f6028232aaf
public void addEmail(String email) { this.email.add(email); }
cc3afbe4-03bd-488b-a0f2-13f34b2b4cfd
public void setDireccion(String direccion){ this.direccion = direccion; }
9ac8e83f-bbca-410c-ad59-82a2b4731057
public String getNombre() { return this.nombre; }
cdbce2e4-7182-4375-8452-dec1b639dba7
public String getDireccion(){ return this.direccion; }
d43a3540-c5be-4700-8221-353c5f48b7e2
public String getApellido() { return this.apellido; }
31c066c1-55fc-4e37-9906-d6db2168200c
public boolean deleteTelefono(String telefono){ if (this.telefonos.contains(telefono)){ this.telefonos.remove(telefono); return true; } return false; }
02662205-dad1-4907-918b-71d8f2565d26
public boolean deleteEmail(String email){ if (this.email.contains(email)){ this.email.remove(email); return true; } return false; }
64312147-5cf4-47ef-84ea-191a97189c02
@Override public String toString() { return "Contacto [nombre=" + this.nombre + ", apellido=" + this.apellido + ", direccion= " + this.direccion + ", telefono=" + this.telefonos.toString() + ", email=" + this.email + "]"; }
dadb60ad-7291-44f1-a0dd-bc9e76cdd56a
@Override public int compareTo(Contacto o) { if (this.apellido.compareToIgnoreCase(o.apellido) > 0) return 1; if (this.apellido.compareToIgnoreCase(o.apellido) < 0) return -1; return 0; }
9beaa734-2fa7-484b-9b0c-b83c2897fe52
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Contacto other = (Contacto) obj; if (apellido == null) { if (other.apellido != null) return false; } else if (!apellido.equals(other.apellido)...
6473123e-8d7c-492e-9029-021e240552ba
ABB () { this.raiz = null; }
ef920f39-9ea9-4e66-9c70-e48de2fe8ac2
public boolean isEmpty() { if (this.raiz == null) return true; else return false; }
97b78297-af32-421e-9a97-cd08766e51b3
public void clear() { this.raiz = null; }
3939547c-9949-48fe-bf2a-a7c9590dba2d
public void insertaABBiterativo(T dato){ NodoArbol<T> noDato = new NodoArbol<T>(dato); int i; if(this.raiz == null) this.raiz = noDato; else{ NodoArbol<T> temp = this.raiz; i = temp.dato.compareTo(dato); NodoArbol<T> pos = null; if(i == 0) return; if(i > 0) pos = temp.izq; if(i < 0) pos = ...
0c2dbfc5-6c58-4f62-9afc-bad6a267a15e
public void insertaABBrecursivo (T dato) { if(this.raiz == null){ NodoArbol<T> noDa = new NodoArbol<T>(dato); this.raiz = noDa; } else insertaABBUtil(this.raiz, dato); }
aa04f8b5-5837-4ac7-92d5-a42d1fc1cb41
private void insertaABBUtil (NodoArbol <T> nodo, T dato) { int i = nodo.dato.compareTo(dato); if(i == 0) return; if(i > 0){ if(nodo.izq == null){ NodoArbol<T> izq = new NodoArbol<T>(dato); nodo.izq = izq; } else insertaABBUtil(nodo.izq, dato); } else{ if(nodo.der == null){...
a6299f8f-90b5-4964-ae10-91765fba3227
public String inOrden() { return inOrdenUtil(this.raiz, ""); }
081e28a6-9757-49df-8f79-596870fc67be
private String inOrdenUtil(NodoArbol <T> nodo, String s) { if(nodo != null){ s += inOrdenUtil(nodo.izq, ""); s+= nodo.dato.toString() + " "; s += inOrdenUtil(nodo.der, ""); } return s; }
a3547aa4-e9dd-478c-aa2c-c40fbb401dd3
public String preOrden() { return preOrdenUtil(this.raiz, ""); }
85983e26-4072-4c95-a216-032bf6fbaaf1
private String preOrdenUtil(NodoArbol <T> nodo, String s) { if(nodo != null){ s+= nodo.dato.toString() + " "; s += preOrdenUtil(nodo.izq, ""); s += preOrdenUtil(nodo.der, ""); } return s; }
1a805f27-0fa9-4130-a37d-b514e5add7db
public String postOrden() { return postOrdenUtil(this.raiz, ""); }
2d50b4ed-398a-40f9-b5ec-f671b4299d88
private String postOrdenUtil(NodoArbol <T> nodo, String s) { if(nodo != null){ s += postOrdenUtil(nodo.izq, ""); s += postOrdenUtil(nodo.der, ""); s+= nodo.dato.toString() + " "; } return s; }
94026b04-cc2b-46d7-8782-9639fbe2d44f
private NodoArbol <T> predecesor(NodoArbol <T> nodo) { if(nodo == null) return null; NodoArbol<T> temp; temp = nodo.izq; while(temp.der != null){ temp = temp.der; } return temp; }
2a2540a3-58a6-45aa-b711-9765f1f93935
private NodoArbol <T> sucesor(NodoArbol<T> nodo) { if(nodo == null) return null; NodoArbol<T> temp; temp = nodo.der; while(temp.izq != null){ temp = temp.izq; } return temp; }
a0b324a4-4782-4f12-90ad-f4efa3cc673e
public T getMayorABB() { NodoArbol<T> temp = this.raiz; if (temp == null) return null; while(temp.der != null){ temp = temp.der; } return temp.dato; }
4b82e913-2199-4ff4-a42c-fd3c4fc51c5e
public T getMenorABB() { NodoArbol<T> temp = this.raiz; if (temp == null) return null; while(temp.izq != null){ temp = temp.izq; } return temp.dato; }
52d413bf-4ec3-445a-bc9e-cd1c6e8aceb3
public int getTotalNodosTerminalesRecursivo() { if(this.raiz == null) return 0; return getTotalNodosTerminalesUtil(this.raiz, 0); }
5954aa34-1c96-444c-b64a-5e04394b94fc
private int getTotalNodosTerminalesUtil (NodoArbol <T> nodo, int total) { if(nodo != null){ total = getTotalNodosTerminalesUtil(nodo.izq, total); total = getTotalNodosTerminalesUtil(nodo.der, total); if (nodo.izq == null && nodo.der == null) total++; } return total; }
314d54a4-f2b9-4a63-b80c-d99217030b4c
public int contarNodosRecursivo() { if(this.raiz == null) return 0; return contarNodosUtil(this.raiz, 0); }
fbd811df-2298-461e-9fe4-c833820eb7d1
private int contarNodosUtil (NodoArbol <T> nodo, int total) { if(nodo != null){ total = contarNodosUtil(nodo.izq, total); total = contarNodosUtil(nodo.der, total); total++; } return total; }
d9974272-7173-4b51-a64c-daf5d2ea6d2f
public T getHermanoABBRecursivo (T dato) { if(this.raiz == null) return null; return(getHermanoABBUtil(this.raiz, dato)); }
d0df60e0-539f-408e-81b9-2e91035acbac
private T getHermanoABBUtil(NodoArbol <T> nodo, T dato) { int i; if(nodo == null || nodo.dato == null) return null; if(containsABBRecursivo(dato) == false) return null; if(dato == this.raiz.dato) return null; if(nodo.der.dato.compareTo(dato)...
32fb1902-db51-44a9-aa1e-530f14db0eba
public T getPadreABBRecursivo (T dato) { if(this.raiz == null || this.raiz.dato.compareTo(dato)==0) return null; return getPadreABBUtil(this.raiz, dato); }
7a14a5f4-17dd-477b-8a93-23e846fc056e
private T getPadreABBUtil (NodoArbol <T> nodo, T dato) { if(nodo == null) return null; if( nodo.der != null && nodo.der.dato.compareTo(dato) == 0 || nodo.izq != null && nodo.izq.dato.compareTo(dato) == 0) return nodo.dato; int i = nodo.dato.compareTo(dato); if(i > 0) re...
ab4daccf-77aa-44ec-8c4f-30b93c35fcc0
public boolean containsABBRecursivo(T dato) { if(this.raiz == null) return false; else return containsABBUtil(this.raiz, dato); }
f61fd0bf-9f7e-49b1-bd73-d82e156df660
private boolean containsABBUtil(NodoArbol <T> nodo, T dato) { if(nodo == null) return false; int i = nodo.dato.compareTo(dato); if(i == 0) return true; if(i > 0) return containsABBUtil(nodo.izq, dato); else return containsABBUtil(nodo.der, dato); }
d7501ca0-b31b-4697-b406-758a5eea6632
public boolean containsABBIterativo(T dato) { NodoArbol<T> temp = new NodoArbol<T>(); temp = this.raiz; int i; while(temp != null){ if(temp.dato == dato) return true; i= temp.dato.compareTo(dato); if(i > 0) temp = temp.izq; else ...
e106ee39-d6ee-4419-ab84-85758f2c47e4
public boolean eliminaDatoABB(T dato){ //NodoArbol<T> nodo = new NodoArbol<T>(dato); if(this.raiz == null) return false; else eliminaDatoABBUtil(this.raiz, dato); return false; }
64d8f50a-1253-46fb-bd12-1e9a07adda6a
private boolean eliminaDatoABBUtil(NodoArbol<T> nodo, T dato){ NodoArbol<T> temp; if(nodo==null) return false; if(nodo.dato==null) return false; int i = nodo.dato.compareTo(dato); if(i==0){ // Si es un nodo hoja if(nodo.izq == n...
21ebff68-182e-48d7-88b0-816b50604fc1
private NodoArbol <T> getNodoPadreABBRecursivo (T dato) { if(this.raiz == null || this.raiz.dato.compareTo(dato)==0) return null; return getNodoPadre(this.raiz, dato); }
0279d53b-3af7-4399-937e-835d4d171ba2
private NodoArbol <T> getNodoPadre(NodoArbol<T> nodo, T dato){ if(nodo == null) return null; if(nodo.der != null && nodo.der.dato.compareTo(dato) == 0 || nodo.izq != null && nodo.izq.dato.compareTo(dato) == 0) return nodo; int i = nodo.dato.compareTo(dato); if(i > 0) ...
6f8ca3fd-5f50-4999-bab2-e23f5e7f6c85
NodoArbol () { dato = null; der = null; izq = null; }
519412c8-b353-49d6-adff-b397f274e99d
NodoArbol(T d) { dato = d; der = null; izq = null; }
3d952d7c-e9a9-493e-9223-90d29683254f
public static void main (String args[]) { ABB <Integer> p = new ABB <Integer> (); int i; System.out.println("Insertando nodos recursivamente."); p.insertaABBrecursivo(60); p.insertaABBrecursivo(13); p.insertaABBrecursivo(85); p.insertaABBrecursivo(75); ...
23561cc1-51cf-4c8b-a666-8c3d5720ef01
public AgendaTreeSet(TreeSet<Contacto> arbol){ //this.agenda = arbol; agenda = new TreeSet<Contacto>(); Iterator<Contacto> iter = arbol.iterator(); Contacto c; while(iter.hasNext()){ c = iter.next(); if(c != null) agenda.add(c); ...
ad4a3974-780f-4a53-884f-8391b43cf5b2
public String contactos(){ String s= ""; Iterator<Contacto> iter = this.agenda.iterator(); while(iter.hasNext()){ s+= iter.next().toString() + " \n"; } return s; }
e3924a83-4562-400b-8a8c-401932ff50c6
public boolean addContacto(Contacto c){ if(agenda.contains(c)) return false; else{ agenda.add(c); return true; } }
a4569bc2-aee4-4be7-9b44-9ecd2cf20ce9
public boolean eliminaContacto(Contacto c){ Iterator<Contacto> iter = this.agenda.iterator(); if(agenda.contains(c)){ while(iter.hasNext()){ if(iter.next().compareTo(c) == 0) iter.remove(); } return true; } return false; }
43e8f6ee-e63f-4f18-85fc-32105b878ff9
public boolean actualizarDir(Contacto c, String d){ Iterator<Contacto> iter = this.agenda.iterator(); Contacto co; if(this.agenda.contains(c)){ while(iter.hasNext()){ co= iter.next(); if(co.compareTo(c) == 0) co.setDireccion(d); } return true; } return false; }
73a36948-338d-4142-babe-411b7a780c27
public boolean agregarTelefono(Contacto c, String string) { Iterator<Contacto> iter = this.agenda.iterator(); Contacto co; if(this.agenda.contains(c)){ while(iter.hasNext()){ co= iter.next(); if(co.compareTo(c) == 0) co.addTelefono(string); } return true; } return false; }
b1fa5055-e50d-47be-8369-86779c9acf91
public boolean agregarEmail(Contacto c, String string) { Iterator<Contacto> iter = this.agenda.iterator(); Contacto co; if(this.agenda.contains(c)){ while(iter.hasNext()){ co= iter.next(); if(co.compareTo(c) == 0) co.addEmail(string); } return true; } return false; }
50b038c7-9633-4c2c-93da-2ef62295b007
public boolean borrarTelefono(Contacto c, String string) { Iterator<Contacto> iter = this.agenda.iterator(); Contacto co; if(this.agenda.contains(c)){ while(iter.hasNext()){ co= iter.next(); if(co.compareTo(c) == 0) co.deleteTelefono(string); } return true; } return false; }
a93740c8-1f9a-47aa-a0dd-6d6ae060e3b1
public String consultarContacto(String string, String string2) { Iterator<Contacto> iter = this.agenda.iterator(); Contacto co, c; String s = ""; c = new Contacto(string, string2, null, null); if(this.agenda.contains(c)){ while(iter.hasNext()){ co= iter.next(); if(co.compareTo(c) == 0) s =...
390e0916-a91d-4356-898a-67a5880f3e61
public boolean borrarMail(Contacto c, String string) { Iterator<Contacto> iter = this.agenda.iterator(); Contacto co; if(this.agenda.contains(c)){ while(iter.hasNext()){ co= iter.next(); if(co.compareTo(c) == 0) co.deleteEmail(string); } return true; } return false; }
4ffb60f6-e82c-46d8-9c49-50a177c51cbe
public int longitud() { Iterator<Contacto> iter = this.agenda.iterator(); int n = 0; while(iter.hasNext()){ n++; iter.next(); } return n; }
4ebe522e-e037-413f-8412-d9c2b5ff0dad
public Model() { students = new Vector<Student>(); }
5ca83227-e185-4abe-b93d-4141948d427b
public void addStudent(final Student student) { if (student != null) { students.add(student); } }
9ca1dc96-ab57-4081-9ee5-8a9d24e4d5c9
public void deleteStudents(final List<Student> delStudents) { for (final Student student : delStudents) { if (students.contains(student)) { students.remove(student); } } }
c6a8e13d-26e8-41f0-bb33-fa266533cde8
private final int getCurrPage() { return currPage; }
9ad812a9-b061-49f7-8920-a1cce27bc70b
public final List<Student> getCurrPageOfStudent() { if (getCurrPage() < 0) { resetCurrPage(); } return getPageOfStudents(); }
a48eec74-2fdb-4442-bc48-0bfbeb5ff0ef
private int getMaxPage() { final double max = (double) students.size() / (double) viewSize; int result = students.size() / viewSize; if (isNeedRounding(max)) { result += 1; } return result; }
4b65834b-4b15-4b3f-8e35-3656edef13ea
public List<Student> getNextPageOfStudents() { leafNext(); return getPageOfStudents(); }
fe236dc6-331d-4dac-b1c0-601b64a10f3b
private List<Student> getPageOfStudents() { final List<Student> pageStudents = new Vector<Student>(); if (students.size() == 0 || currPage < 0 || currPage >= getMaxPage()) { return pageStudents; } int size = 0; if (students.size() - viewSize * currPage < viewSize) { size = students.size() - viewSize * ...
a2dd3d02-2d5d-43cc-9b26-160b17fae166
public List<Student> getPrevPageOfStudents() { leafPrev(); return getPageOfStudents(); }
e950942a-6eb4-4970-8f78-00bc5b7b6ca9
public int getStudentsCount() { return students.size(); }
e190ea3b-de0f-4051-9e16-6fb8337e15f5
public final Integer getViewSize() { return viewSize; }
79526acc-90a6-48f2-8200-d248d6e56d9f
private boolean isNeedRounding(final double max) { return max % 2 != 0 && max % 2 != 1; }
940647f2-c491-45cd-95b9-3034fdf115c6
public void leafNext() { if (currPage < getMaxPage() - 1) { currPage++; } }
fa200efb-bb54-4be3-91c5-1ca6213997ff
public void leafPrev() { if (currPage > 0) { currPage--; } }
c06160ea-8c99-44e6-8edf-93063fc7109b
public void openXML(final File file) { final XMLReader reader = new XMLReader(); reader.openXML(file, this); }
df3b6449-139b-4bdc-9e16-aa6283fb8b0e
private void resetCurrPage() { currPage = 0; }
55f6e138-7dd0-4721-8164-132db7422a69
public void saveXML(final File file) { final XMLWriter xmlWriter = new XMLWriter(); xmlWriter.saveXML(file, students); }
d10856f1-3e81-4587-bb98-a9abc52e88c4
public Vector<Student> search(final String name, final Integer group) { final Vector<Student> studentsVector = new Vector<Student>(); for (final Student student : students) { if (student.getName().indexOf(name) != -1) { if (group != null) { if (student.getGroup().toString().indexOf(group.toString()) !=...
4effc40b-bec1-4ac7-86ba-7c50b81419c7
public Vector<Student> search(final String name, final String botStr, final String topStr) { final Vector<Student> studentsVector = new Vector<Student>(); final int bot = Util.isNumeric(botStr) ? Integer.parseInt(botStr) : 0; final int top = Util.isNumeric(topStr) ? Integer.parseInt(topStr) : 10; for (final...
2c94ac50-6c64-4668-a006-51d9796a8124
public Vector<Student> search(final String name, final String examStr, final String botStr, final String topStr) { final Vector<Student> studentsVector = new Vector<Student>(); final int bot = Util.isNumeric(botStr) ? Integer.parseInt(botStr) : 0; final int top = Util.isNumeric(topStr) ? Integer.parseInt(topS...
9671c2e3-6101-40bc-962f-74f826609f9c
public void setStudents(final List<Student> students) { this.students.clear(); this.students.addAll(students); }
ec847f84-0803-4ab5-91c1-d6b3e785245a
public void setViewSize(final Integer viewSize) { if (viewSize != null) { if (viewSize > 0) { this.viewSize = viewSize; } } }
9d5267e4-f3fd-43c8-9cae-e29474bee33c
public Student(final String name, final Integer group, final Exam... exams) { this.name = name; this.group = group; this.exams = new ArrayList<Exam>(); for (final Exam exam : exams) { this.exams.add(exam); } }
511652e5-c1bb-4fd4-acaa-72e3efd998fb
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Student other = (Student) obj; if (exams == null) { if (other.exams != null) { return false; } } else ...
ae85d903-7ad7-43d5-988f-f56cf26b3622
public double getAverageMark() { double result = 0; int counter = 0; for (final Exam exam : exams) { if (exam.getMark() != null) { result += exam.getMark(); counter++; } } result = result / counter; return result; }
9c45f525-2940-446b-a9d2-e236943567c6
public final List<Exam> getExams() { return exams; }
082215c9-6e6f-452c-9524-1c2fd50b8cf0
public final Exam getExams(final int num) { return num < exams.size() && num >= 0 ? exams.get(num) : null; }
2639b37a-4c30-4862-81ac-06f3df668383
public final Integer getGroup() { return group; }
488b5783-0363-4ad7-acfd-a071dd0d0041
public final String getName() { return name; }
8f5d0d5e-4a25-4a34-9063-d5ad604f400a
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((exams == null) ? 0 : exams.hashCode()); result = prime * result + ((group == null) ? 0 : group.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; }
0b2b969f-7290-4748-8d33-9d2845aba317
public double isExam(final String examName) { double result = -1; double counter = 0; for (final Exam exam : exams) { if (exam.getName() != null) { if (exam.getName().indexOf(examName) != -1) { result += exam.getMark() != null ? exam.getMark() : 0; counter++; } } } if (counter > 0) { ...
2c248af7-533a-45f4-873f-2844481a0c77
@Override public void error(final SAXParseException exception) throws SAXException { // exception.printStackTrace(); LOG.log(Level.SEVERE, "Error in parsing: " + exception.getMessage(), exception); }
0ca24d88-7698-4335-a395-0ed959bba4e1
@Override public void fatalError(final SAXParseException exception) throws SAXException { // exception.printStackTrace(); LOG.log(Level.SEVERE, "Error in parsing: " + exception.getMessage(), exception); }
1fbad410-79d4-4970-8a99-b4f9a1e39467
@Override public void warning(final SAXParseException exception) throws SAXException { // exception.printStackTrace(); LOG.log(Level.SEVERE, "Error in parsing: " + exception.getMessage(), exception); }
6619e225-6e14-4b29-8b49-799b61d16bfc
public static void addFile(final String key, final String value) { Files.files.put(key, value); }
41292476-472e-477c-bd98-49ab8e2c719b
public static String getAddress(final String key) { if (Files.files.containsKey(key)) { return Files.files.get(key); } else { return null; } }
d6f979e8-ce6d-4f99-97d5-5b1c224c9fb7
public static List<Object> getObjectKeys() { final List<Object> strings = new ArrayList<Object>(); strings.addAll(Files.files.keySet()); return strings; }
b2d8841d-916b-406a-b32f-08dd51086c88
public static Set<String> getObjects() { return Files.files.keySet(); }
4f31ce54-b842-4862-a4a3-d6f3c6a286a7
public static int size() { return Files.files.size(); }
28667796-c3da-456c-92e6-c2199af675fd
public Document createDocument(final List<Student> students) { Document doc = null; try { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); final DocumentBuilder db = dbf.newDocumentBuilder(); doc = db.newDocument(); final Element root = doc.createElem...
d8b46716-b595-422e-88a4-a13f571e49e9
private void newElement(final Document doc, final String name, final Element studentElement, final String text) { Element element; Text textElement; element = doc.createElement(name); textElement = doc.createTextNode(text); studentElement.appendChild(element); element.appendChild(textElement); }
11edac2b-58e3-4918-a34b-f15e94890ea5
public void saveXML(final File file, final List<Student> students) { final XMLWriter xmlWriter = new XMLWriter(); final Document doc = createDocument(students); if (doc != null) { writeToFile(file.getPath(), doc); } else { JOptionPane.showMessageDialog(null, Model.ERROR_ERROR_IN_CREATING_DOC); XMLWrit...
dfec4162-ed9c-4b4d-8938-e5042bffaf2e
private void writeToFile(final String xml, final Document doc) throws TransformerFactoryConfigurationError { try { final Transformer tr = TransformerFactory.newInstance().newTransformer(); tr.setOutputProperty(OutputKeys.INDENT, "yes"); tr.setOutputProperty(OutputKeys.METHOD, "xml"); tr.setOutputPrope...
16b9e961-f20b-40fe-9885-24a2285112eb
public Exam(final String name, final Integer mark) { this.name = name; this.mark = mark; }