Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Jhaymayleth/unidad2_java/llms.txt

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

This guide gets you running the first Taller 7 exercise — the Empleado class — locally in just a few commands. The exercise demonstrates access modifiers and encapsulation: a public name field, a private salary field, and a setter that validates input before applying changes.
1

Clone the repository

Clone the repo from GitHub and move into the project directory:
git clone https://github.com/Jhaymayleth/unidad2_java.git && cd unidad2_java
2

Check your Java version

Confirm you have Java 11 or later installed:
java -version
You should see output similar to openjdk version "11.x.x" or higher. If Java is not installed, download it from adoptium.net before continuing.
3

Compile the Taller 7 Exercise 1 sources

From the repository root, compile both the Empleado class and its test driver together:
javac Taller7/ejercicio_1/Empleado.java Taller7/ejercicio_1/PruebaEjercicio1.java
The compiler respects the package Taller7.ejercicio_1; declarations in both files, so always run this command from the repository root.
4

Run the program

Launch the compiled program using the fully qualified class name:
java Taller7.ejercicio_1.PruebaEjercicio1
5

Expected output

If everything compiled correctly you will see the following console output:
========== EJERCICIO 1: CLASE EMPLEADO ==========

1. Creando empleados:
==================================================

✅ Salario actualizado correctamente: $2500.00

--- Información del Empleado ---
Nombre: Juan García
Salario: $2500.00

✅ Salario actualizado correctamente: $3000.00

--- Información del Empleado ---
Nombre: María López
Salario: $3000.00

==================================================

2. Accediendo directamente al atributo público 'nombre':
==================================================

Nombre de emp1: Juan García
Nombre de emp2: María López

==================================================

3. Modificando directamente el atributo público 'nombre':
==================================================

Nuevo nombre de emp1: Juan Carlos García

--- Información del Empleado ---
Nombre: Juan Carlos García
Salario: $2500.00

==================================================

4. Usando getter para obtener el salario (privado):
==================================================

Salario de emp1: $2500.00
Salario de emp2: $3000.00

==================================================

5. Usando setter con validación:
==================================================

Intentando establecer un salario válido (3500):
✅ Salario actualizado correctamente: $3500.00

Intentando establecer un salario inválido (-1000):
❌ Error: El salario debe ser mayor a 0. Salario no actualizado.

Intentando establecer un salario inválido (0):
❌ Error: El salario debe ser mayor a 0. Salario no actualizado.

Intentando establecer un salario válido (2800):
✅ Salario actualizado correctamente: $2800.00

==================================================

6. Información actualizada:
==================================================

--- Información del Empleado ---
Nombre: Juan Carlos García
Salario: $2800.00

--- Información del Empleado ---
Nombre: María López
Salario: $3000.00

==================================================

7. Calculando bono anual (10% del salario):
==================================================

Bono anual de emp1: $280.00
Bono anual de emp2: $300.00

==================================================

8. Aumentando salario por porcentaje (5%):
==================================================

Salario actual de emp2: $3000.00
✅ Salario actualizado correctamente: $3150.00
Nuevo salario de emp2: $3150.00

==================================================

9. Resumen final de empleados:
==================================================

--- Información del Empleado ---
Nombre: Juan Carlos García
Salario: $2800.00

--- Información del Empleado ---
Nombre: María López
Salario: $3150.00

==================================================

Running Any Exercise

Every exercise across all six talleres follows the same two-step pattern:
  1. Compile from the repository root, listing all .java files that belong to the exercise:
    javac <TallerN>/<ejercicioN>/<ClassName>.java <TallerN>/<ejercicioN>/<MainClass>.java
    
  2. Run using the fully qualified class name that mirrors the package declaration:
    java <TallerN>.<ejercicioN>.<MainClass>
    
For example, to run Taller 8 Exercise 2 (PersonaEstudiante):
javac taller8/ejercicio2/Persona.java taller8/ejercicio2/Estudiante.java taller8/ejercicio2/PruebaEjercicio2.java
java taller8.ejercicio2.PruebaEjercicio2
Most exercises use package declarations. Always compile from the repository root and reference the fully qualified class name when running.

Next Steps

Taller 7 Overview

Dive deeper into access modifiers, encapsulation, and all three Taller 7 exercises.

Access Modifiers Concept

Read the conceptual guide to public, private, and protected in Java.

Build docs developers (and LLMs) love