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.

MatrizSemestres in estructuras.MatrizSemestres is a two-dimensional array Curso[filas][columnas] with a default size of 10×10. The first dimension (rows) represents academic semesters 1 through 10 using a zero-based index — semester n maps to row n − 1. The second dimension (columns) provides up to 10 open slots per semester, filled left-to-right; a null cell is an empty slot. This layout directly mirrors the grid panel in the UI, where each row of the visual table corresponds to one semester row in the matrix.

Matrix Layout

The table below shows how semesters and array indices relate. Each cell at [row][col] holds a Curso reference or null.
Row indexSemesterMax courses per row
0Semester 110
1Semester 210
8Semester 910
9Semester 1010
Courses are placed in the first available null column of the target row. Once all 10 columns of a row are occupied, insertarPorSemestre returns false and the caller must handle the overflow case.

Public API

1

MatrizSemestres() / MatrizSemestres(int filas, int columnas)

The no-argument constructor initialises a Curso[10][10] array — the standard configuration for a 10-semester programme. The parameterised constructor allows alternative dimensions for custom use cases.
public MatrizSemestres() {
    this(10, 10); // 10 semesters × 10 slots each
}

public MatrizSemestres(int filas, int columnas) {
    this.filas    = filas;
    this.columnas = columnas;
    matriz = new Curso[filas][columnas];
}
2

insertarPorSemestre(Curso curso)

Reads curso.getSemestre(), subtracts 1 to obtain the zero-based row index, then scans columns left-to-right for the first null cell. Inserts there and returns true. Returns false if the semester index is out of bounds or the row is full.
public boolean insertarPorSemestre(Curso curso) {
    int fila = curso.getSemestre() - 1;
    if (fila < 0 || fila >= filas) return false;

    for (int col = 0; col < columnas; col++) {
        if (matriz[fila][col] == null) {
            matriz[fila][col] = curso;
            return true;
        }
    }
    return false; // Row is full
}
3

eliminarPorCodigo(String codigo, int semestre)

Converts semestre to a row index, then scans that row for a cell whose getCodigo() matches codigo (case-insensitive). Nulls the cell and returns true. Returns false if the row is out of range or the code is not found in that row. Complexity O(columnas).
4

actualizarCurso(String codigo, Curso actualizado)

Performs a full matrix scan to find the cell containing the course with the given code. If the new Curso has a different semestre value, the old cell is set to null and insertarPorSemestre(actualizado) places it in the correct new row. If the semester is unchanged, the cell is replaced in-place. Returns true if the code was found. Complexity O(filas × columnas) worst case.
5

limpiar()

Iterates the entire matrix and sets every cell to null. Used during data reload from persistence. Complexity O(filas × columnas).

Semester Change Handling

When actualizarCurso detects that cursoActual.getSemestre() != actualizado.getSemestre(), it executes a two-step relocation:
  1. Remove from old row — sets matriz[fila][col] = null, freeing the slot in the original semester row.
  2. Insert into new row — calls insertarPorSemestre(actualizado), which places the updated course in the first free slot of the new semester row.
This ensures no duplicate entries and no orphaned cells exist after a semester-change update.
public boolean actualizarCurso(String codigo, Curso actualizado) {
    for (int fila = 0; fila < filas; fila++) {
        for (int col = 0; col < columnas; col++) {
            Curso cursoActual = matriz[fila][col];
            if (cursoActual != null && cursoActual.getCodigo().equalsIgnoreCase(codigo)) {
                if (cursoActual.getSemestre() != actualizado.getSemestre()) {
                    matriz[fila][col] = null;              // 1. free old slot
                    return insertarPorSemestre(actualizado); // 2. place in new row
                }
                matriz[fila][col] = actualizado; // Same semester — update in place
                return true;
            }
        }
    }
    return false;
}

Usage Example

MatrizSemestres matriz = new MatrizSemestres();

Curso c = new Curso("AED101", "Algoritmos", 4, 2);
matriz.insertarPorSemestre(c);  // Inserts at row 1 (semestre 2 − 1), column 0

// Update course — semester changes from 2 to 3
Curso actualizado = new Curso("AED101", "Algoritmos y ED", 4, 3);
matriz.actualizarCurso("AED101", actualizado);  // Moves from row 1 to row 2

// Remove a course directly
matriz.eliminarPorCodigo("AED101", 3);
All three course structures — ArregloCursos, ListaCursos, and MatrizSemestres — must be kept synchronised at all times. Inserting, updating, or deleting a course must be applied to all three in a single coordinated operation; failing to do so will cause the semester grid panel, the combo-boxes, and the Excel export to show inconsistent data.

Build docs developers (and LLMs) love