Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/kenri89/PROYECTO_UTP_AED_1_1/llms.txt

Use this file to discover all available pages before exploring further.

ListaMatricula in estructuras.ListaMatricula is a singly-linked list whose elements are Matricula model objects. New records are always appended at the tail to preserve insertion order. The identity of an enrollment record is the composite pair (carnet, codigoCurso) — there is no auto-generated numeric ID. All string comparisons across the list use equalsIgnoreCase so that carnet and course-code casing differences never cause silent mismatches.

Internal Node Structure

Each node holds a single Matricula reference and a pointer to the next node. The node class is a private static inner class not visible to callers.
private static class Nodo {
    Matricula matricula;
    Nodo siguiente;

    Nodo(Matricula matricula) {
        this.matricula = matricula;
        this.siguiente = null;
    }
}
The list tracks a head pointer (inicio) and an integer tamaño (logical size) that is incremented on every successful agregar and decremented on every successful eliminar.

Public API

1

agregar(Matricula matricula)

Appends a new node at the tail. Traverses from inicio until siguiente == null, then links the new node. Complexity O(n) because there is no cached tail pointer.
public void agregar(Matricula matricula) {
    Nodo nuevo = new Nodo(matricula);
    if (estaVacia()) {
        inicio = nuevo;
    } else {
        Nodo actual = inicio;
        while (actual.siguiente != null) {
            actual = actual.siguiente;
        }
        actual.siguiente = nuevo;
    }
    tamaño++;
}
2

eliminar(String carnet, String codigoCurso)

Finds and unlinks the node whose enrollment identity matches (carnet, codigoCurso). Handles the head-node case separately. Returns true if a node was removed, false if not found. Complexity O(n).
public boolean eliminar(String carnet, String codigoCurso) {
    if (estaVacia()) return false;

    if (inicio.matricula.getEstudiante().getCarnet().equalsIgnoreCase(carnet)
            && inicio.matricula.getCurso().getCodigo().equalsIgnoreCase(codigoCurso)) {
        inicio = inicio.siguiente;
        tamaño--;
        return true;
    }
    // ... traverse to predecessor and re-link
}
3

actualizar(String carnet, String codigoCurso, Estudiante nuevoEstudiante)

Locates the record by identity pair and replaces its Estudiante reference via matricula.setEstudiante(nuevoEstudiante). This is used when a student’s name or career is edited and all their enrollment records must reflect the change. Returns true on success. Complexity O(n).
4

buscar(String carnet, String codigoCurso)

Returns the first Matricula whose identity pair matches exactly, or null if not present. Used by the enrollment panel to prevent duplicate registrations. Complexity O(n).
public Matricula buscar(String carnet, String codigoCurso) {
    Nodo actual = inicio;
    while (actual != null) {
        if (actual.matricula.getEstudiante().getCarnet().equalsIgnoreCase(carnet)
                && actual.matricula.getCurso().getCodigo().equalsIgnoreCase(codigoCurso)) {
            return actual.matricula;
        }
        actual = actual.siguiente;
    }
    return null;
}
5

buscarPorCarnet(String carnet)

Traverses the entire list and collects every Matricula where the student carnet matches. Returns a List<Matricula> (uses java.util.ArrayList only as a return vessel — the linked list itself is the storage). Complexity O(n). Used by PanelMisMatriculas to display all courses a student is enrolled in.
public List<Matricula> buscarPorCarnet(String carnet) {
    List<Matricula> filtradas = new ArrayList<>();
    Nodo actual = inicio;
    while (actual != null) {
        if (actual.matricula.getEstudiante().getCarnet().equalsIgnoreCase(carnet)) {
            filtradas.add(actual.matricula);
        }
        actual = actual.siguiente;
    }
    return filtradas;
}
6

recorrer(Consumer<Matricula> accion)

Full list traversal using a Consumer<Matricula> lambda. Used for persistence serialization (writing every record to the data file) and for populating the enrollment table in the UI thread. Complexity O(n).
7

Utility methods

boolean estaVacia() — returns true when inicio == null.int getTamaño() — returns the cached tamaño counter. O(1).void limpiar() — sets inicio = null and resets tamaño to 0.

Case-Insensitive Matching

All carnet and course-code comparisons inside the list use equalsIgnoreCase. This means "AED101", "aed101", and "Aed101" are treated as the same course code when searching, updating, or deleting records. The approach avoids user-input inconsistencies without forcing normalisation at the model layer.

Usage Example

ListaMatricula lista = new ListaMatricula();
lista.agregar(new Matricula(estudiante, curso));

// Exact lookup to prevent duplicate registration
Matricula m = lista.buscar("2024001", "AED101");

// Retrieve all courses for one student
List<Matricula> misMatriculas = lista.buscarPorCarnet("2024001");

// Traverse for display or persistence
lista.recorrer(mat -> System.out.println(mat.getEstudiante().getNombre()));

// Cancel a specific enrollment
lista.eliminar("2024001", "AED101");

Build docs developers (and LLMs) love