diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..a0ccf77b
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Environment-dependent path to Maven home directory
+/mavenHomeManager.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 00000000..dc0150e8
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 00000000..c5409715
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/homework-java-ironschool.iml b/.idea/homework-java-ironschool.iml
new file mode 100644
index 00000000..d6ebd480
--- /dev/null
+++ b/.idea/homework-java-ironschool.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 00000000..712ab9d9
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..d29b440d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..7d988043
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/IronSchool/pom.xml b/IronSchool/pom.xml
new file mode 100644
index 00000000..29c2211e
--- /dev/null
+++ b/IronSchool/pom.xml
@@ -0,0 +1,25 @@
+
+4.0.0
+org.example
+ironschool-project
+1.0-SNAPSHOT
+
+ 21
+ 21
+ UTF-8
+
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.10.0
+ test
+
+
+
\ No newline at end of file
diff --git a/IronSchool/src/main/java/Course.java b/IronSchool/src/main/java/Course.java
new file mode 100644
index 00000000..4b59de31
--- /dev/null
+++ b/IronSchool/src/main/java/Course.java
@@ -0,0 +1,76 @@
+import java.util.UUID;
+
+public class Course {
+ private String courseId;
+ private String name;
+ private double price;
+ private double money_earned;
+ private Teacher teacher;
+
+ // constructor crear nuevo curso
+ private static int idCounter = 1000;
+ public Course(String name, double price) {
+ this.courseId = "C" + idCounter++; // Genera un ID único
+ this.name = name;
+ this.price = price;
+ this.money_earned = 0.0; // De primeras no hay dinero ganado
+ this.teacher = null; // no hay profesor asignado al principio
+ }
+
+ // Getters - Setters__
+
+ public String getCourseId() {
+ return courseId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+
+ public double getMoney_earned() {
+ return money_earned;
+ }
+
+ public void setMoney_earned(double money_earned) {
+ this.money_earned = money_earned;
+ }
+
+ public Teacher getTeacher() {
+ return teacher;
+ }
+
+ public void setTeacher(Teacher teacher) {
+ this.teacher = teacher;
+ }
+
+ // Incrementar el dinero ganado cuando se inscriben a curso
+
+ public void updateMoneyEarned() {
+ this.money_earned += this.price;
+ }
+ public void enrollStudent() {
+ this.money_earned += this.price;
+ }
+ // representacion en string del curso
+
+ @Override
+ public String toString() {
+ return "Curso [ID: " + courseId + ", Nombre: " + name +
+ ", Precio: " + price + ", Dinero ganado: " + money_earned +
+ ", Profesor: " + (teacher != null ? teacher.getName() : "No asignado") + "]";
+ }
+
+}
+
diff --git a/IronSchool/src/main/java/SchoolApp.java b/IronSchool/src/main/java/SchoolApp.java
new file mode 100644
index 00000000..e86dce78
--- /dev/null
+++ b/IronSchool/src/main/java/SchoolApp.java
@@ -0,0 +1,199 @@
+import java.util.*;
+// aplicacion final
+
+
+public class SchoolApp {
+ private static final Scanner scanner = new Scanner(System.in);
+ private static final Map teachers = new HashMap<>();
+ private static final Map courses = new HashMap<>();
+ private static final Map students = new HashMap<>();
+
+ public static void main(String[] args) {
+ System.out.print("Enter school name: ");
+ String schoolName = scanner.nextLine();
+ System.out.println("Welcome to " + schoolName + " School Management System!");
+
+ createTeachers();
+ createCourses();
+ createStudents();
+
+ while (true) {
+ showMenu();
+ System.out.print("Choose an option (0 to exit): ");
+ String input = scanner.nextLine().trim();
+ switch (input) {
+ case "1":
+ System.out.println("Enroll a student into a course");
+ enrollOption();
+ break;
+ case "2":
+ System.out.println("Assign a teacher to a course");
+ assignOption();
+ break;
+ case "3":
+ System.out.println("All courses:");
+ showCourses();
+ break;
+ case "4":
+ System.out.print("Enter Course ID: ");
+ lookupCourse(scanner.nextLine());
+ break;
+ case "5":
+ System.out.println("All students:");
+ showStudents();
+ break;
+ case "6":
+ System.out.print("Enter Student ID: ");
+ lookupStudent(scanner.nextLine());
+ break;
+ case "7":
+ System.out.println("All teachers:");
+ showTeachers();
+ break;
+ case "8":
+ System.out.print("Enter Teacher ID: ");
+ lookupTeacher(scanner.nextLine());
+ break;
+ case "9":
+ showProfit();
+ break;
+ case "0":
+ System.out.println("Exiting program. Goodbye!");
+ return;
+ default:
+ System.out.println("Invalid option. Please enter a number from 0 to 9.");
+ }
+ }
+ }
+
+ private static void showMenu() {
+ System.out.println("\n===== SCHOOL MENU =====");
+ System.out.println("1. Enroll a student into a course");
+ System.out.println("2. Assign a teacher to a course");
+ System.out.println("3. Show all courses");
+ System.out.println("4. Show details of a specific course");
+ System.out.println("5. Show all students");
+ System.out.println("6. Show details of a specific student");
+ System.out.println("7. Show all teachers");
+ System.out.println("8. Show details of a specific teacher");
+ System.out.println("9. Show total profit");
+ System.out.println("0. Exit");
+ }
+
+ private static void enrollOption() {
+ System.out.print("Enter Student ID: ");
+ String studentId = scanner.nextLine();
+ System.out.print("Enter Course ID: ");
+ String courseId = scanner.nextLine();
+ enrollStudent(studentId, courseId);
+ }
+
+ private static void assignOption() {
+ System.out.print("Enter Teacher ID: ");
+ String teacherId = scanner.nextLine();
+ System.out.print("Enter Course ID: ");
+ String courseId = scanner.nextLine();
+ assignTeacher(teacherId, courseId);
+ }
+
+ private static void createTeachers() {
+ System.out.print("How many teachers? ");
+ int count = Integer.parseInt(scanner.nextLine());
+ for (int i = 0; i < count; i++) {
+ System.out.print("Enter teacher name: ");
+ String name = scanner.nextLine();
+ System.out.print("Enter teacher salary: ");
+ double salary = Double.parseDouble(scanner.nextLine());
+ Teacher t = new Teacher(name, salary);
+ teachers.put(t.getTeacherId(), t);
+ System.out.println("Created: " + t);
+ }
+ }
+
+ private static void createCourses() {
+ System.out.print("How many courses? ");
+ int count = Integer.parseInt(scanner.nextLine());
+ for (int i = 0; i < count; i++) {
+ System.out.print("Enter course name: ");
+ String name = scanner.nextLine();
+ System.out.print("Enter course price: ");
+ double price = Double.parseDouble(scanner.nextLine());
+ Course c = new Course(name, price);
+ courses.put(c.getCourseId(), c);
+ System.out.println("Created: " + c);
+ }
+ }
+
+ private static void createStudents() {
+ System.out.print("How many students? ");
+ int count = Integer.parseInt(scanner.nextLine());
+ for (int i = 0; i < count; i++) {
+ System.out.print("Enter student name: ");
+ String name = scanner.nextLine();
+ System.out.print("Enter student address: ");
+ String address = scanner.nextLine();
+ System.out.print("Enter student email: ");
+ String email = scanner.nextLine();
+ Student s = new Student(name, address, email);
+ students.put(s.getStudentId(), s);
+ System.out.println("Created: " + s);
+ }
+ }
+
+ private static void enrollStudent(String studentId, String courseId) {
+ Student s = students.get(studentId);
+ Course c = courses.get(courseId);
+ if (s != null && c != null) {
+ s.setCourse(c);
+ c.enrollStudent();
+ System.out.println("Student enrolled.");
+ } else {
+ System.out.println("Invalid student or course ID.");
+ }
+ }
+
+ private static void assignTeacher(String teacherId, String courseId) {
+ Teacher t = teachers.get(teacherId);
+ Course c = courses.get(courseId);
+ if (t != null && c != null) {
+ c.setTeacher(t);
+ System.out.println("Teacher assigned to course.");
+ } else {
+ System.out.println("Invalid teacher or course ID.");
+ }
+ }
+
+ private static void showCourses() {
+ courses.values().forEach(System.out::println);
+ }
+
+ private static void showStudents() {
+ students.values().forEach(System.out::println);
+ }
+
+ private static void showTeachers() {
+ teachers.values().forEach(System.out::println);
+ }
+
+ private static void lookupCourse(String courseId) {
+ Course c = courses.get(courseId);
+ System.out.println(c != null ? c : "Course not found.");
+ }
+
+ private static void lookupStudent(String studentId) {
+ Student s = students.get(studentId);
+ System.out.println(s != null ? s : "Student not found.");
+ }
+
+ private static void lookupTeacher(String teacherId) {
+ Teacher t = teachers.get(teacherId);
+ System.out.println(t != null ? t : "Teacher not found.");
+ }
+
+ private static void showProfit() {
+ double totalEarned = courses.values().stream().mapToDouble(Course::getMoney_earned).sum();
+ double totalSalaries = teachers.values().stream().mapToDouble(Teacher::getSalary).sum();
+ double profit = totalEarned - totalSalaries;
+ System.out.println("Total Profit: " + profit);
+ }
+}
diff --git a/IronSchool/src/main/java/Student.java b/IronSchool/src/main/java/Student.java
new file mode 100644
index 00000000..4bd62865
--- /dev/null
+++ b/IronSchool/src/main/java/Student.java
@@ -0,0 +1,79 @@
+public class Student {
+ // Private member variables
+ private String studentId;
+ private String name;
+ private String address;
+ private String email;
+ private Course course; // Nullable - represents the course this student is enrolled in
+
+
+ private static int idCounter = 1000;
+
+
+ public Student(String name, String address, String email) {
+ this.studentId = "S" + idCounter++;
+ this.name = name;
+ this.address = address;
+ this.email = email;
+ this.course = null;
+ }
+
+ // Getter methods
+ public String getStudentId() {
+ return studentId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public Course getCourse() {
+ return course;
+ }
+
+ // Setter methods
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public void setCourse(Course course) {
+ this.course = course;
+ }
+
+
+ public void enrollInCourse(Course course) {
+ this.course = course;
+ if (course != null) {
+
+ course.setMoney_earned(course.getMoney_earned() + course.getPrice());
+ }
+ }
+
+
+ @Override
+ public String toString() {
+ String courseInfo = (course != null) ? course.getName() : "Not enrolled";
+ return "Student ID: " + studentId +
+ "\nName: " + name +
+ "\nAddress: " + address +
+ "\nEmail: " + email +
+ "\nCourse: " + courseInfo;
+ }
+}
+
diff --git a/IronSchool/src/main/java/Teacher.java b/IronSchool/src/main/java/Teacher.java
new file mode 100644
index 00000000..fd5ef019
--- /dev/null
+++ b/IronSchool/src/main/java/Teacher.java
@@ -0,0 +1,39 @@
+import java.util.UUID;
+
+public class Teacher {
+ private String teacherId;
+ private String name;
+ private double salary;
+
+ private static int idCounter = 1000;
+ public Teacher(String name, double salary) {
+ this.teacherId = "T" + idCounter++;
+ this.name = name;
+ this.salary = salary;
+ }
+
+ public String getTeacherId() {
+ return teacherId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public double getSalary() {
+ return salary;
+ }
+
+ public void setSalary(double salary) {
+ this.salary = salary;
+ }
+
+ @Override
+ public String toString() {
+ return "ID: " + teacherId + ", Nombre: " + name + ", Salary: " + salary;
+ }
+}
diff --git a/IronSchool/src/main/java/prueba.java b/IronSchool/src/main/java/prueba.java
new file mode 100644
index 00000000..6c844b7b
--- /dev/null
+++ b/IronSchool/src/main/java/prueba.java
@@ -0,0 +1,5 @@
+public class prueba {
+ public static void main(String[] args) {
+
+ }
+}
diff --git a/IronSchool/src/test/java/CourseTest.java b/IronSchool/src/test/java/CourseTest.java
new file mode 100644
index 00000000..6a51826b
--- /dev/null
+++ b/IronSchool/src/test/java/CourseTest.java
@@ -0,0 +1,63 @@
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+ public class CourseTest {
+
+ private Course curso;
+ private final String NOMBRE_CURSO = "Programación Java";
+ private final double PRECIO_CURSO = 1500.0;
+
+ @BeforeEach
+ public void setUp() {
+ curso = new Course(NOMBRE_CURSO, PRECIO_CURSO);
+ }
+
+ @Test
+ public void testConstructor() {
+ assertNotNull(curso.getCourseId());
+ assertEquals(NOMBRE_CURSO, curso.getName());
+ assertEquals(PRECIO_CURSO, curso.getPrice());
+ assertEquals(0.0, curso.getMoney_earned());
+ assertNull(curso.getTeacher());
+ }
+
+ @Test
+ public void testUpdateMoneyEarned() {
+ // inicialmente el dinero ganado es 0
+ assertEquals(0.0, curso.getMoney_earned());
+
+ // Actualizacion de dinero ganado
+ curso.updateMoneyEarned();
+
+ // Verificar dinero ganado sea igual al precio del curso
+ assertEquals(PRECIO_CURSO, curso.getMoney_earned());
+
+ // Actualizar otra vez dinero ganado
+ curso.updateMoneyEarned();
+
+ // Comprobacion de que se haya acumulado correctamente
+ assertEquals(PRECIO_CURSO * 2, curso.getMoney_earned());
+ }
+
+ @Test
+ public void testToString() {
+ String expectedString = "Curso [ID: " + curso.getCourseId() +
+ ", Nombre: " + NOMBRE_CURSO +
+ ", Precio: " + PRECIO_CURSO +
+ ", Dinero ganado: 0.0" +
+ ", Profesor: No asignado]";
+ assertEquals(expectedString, curso.toString());
+
+ // Asignar un profesor y verificar que el toString se actualice
+ Teacher teacher = new Teacher("Juan Pérez", 2500.0);
+ curso.setTeacher(teacher);
+
+ expectedString = "Curso [ID: " + curso.getCourseId() +
+ ", Nombre: " + NOMBRE_CURSO +
+ ", Precio: " + PRECIO_CURSO +
+ ", Dinero ganado: 0.0" +
+ ", Profesor: Juan Pérez]";
+ assertEquals(expectedString, curso.toString());
+ }
+ }
diff --git a/IronSchool/src/test/java/StudentTest.java b/IronSchool/src/test/java/StudentTest.java
new file mode 100644
index 00000000..5243dd8a
--- /dev/null
+++ b/IronSchool/src/test/java/StudentTest.java
@@ -0,0 +1,85 @@
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class StudentTest {
+
+ private Student student;
+ private static final String STUDENT_NAME = "John Doe";
+ private static final String STUDENT_ADDRESS = "123 Main St";
+ private static final String STUDENT_EMAIL = "john.doe@example.com";
+
+ @BeforeEach
+ public void setUp() {
+ student = new Student(STUDENT_NAME, STUDENT_ADDRESS, STUDENT_EMAIL);
+ }
+
+ @Test
+ public void testConstructor() {
+ assertNotNull(student.getStudentId(), "Student ID should not be null");
+ assertEquals(STUDENT_NAME, student.getName(), "Name should be set correctly");
+ assertEquals(STUDENT_ADDRESS, student.getAddress(), "Address should be set correctly");
+ assertEquals(STUDENT_EMAIL, student.getEmail(), "Email should be set correctly");
+ assertNull(student.getCourse(), "Course should initially be null");
+ }
+
+ @Test
+ public void testUniqueIDs() {
+ Student anotherStudent = new Student("Jane Smith", "456 Oak Ave", "jane@example.com");
+ assertNotEquals(student.getStudentId(), anotherStudent.getStudentId(),
+ "Different students should have different IDs");
+ }
+
+ @Test
+ public void testEnrollInCourse() {
+ Course course = new Course("Java Programming", 999.99);
+ double initialMoneyEarned = course.getMoney_earned();
+
+ student.enrollInCourse(course);
+
+ assertEquals(course, student.getCourse(), "Student should be enrolled in the course");
+ assertEquals(initialMoneyEarned + course.getPrice(), course.getMoney_earned(), 0.001,
+ "Course money earned should increase by course price");
+ }
+
+ @Test
+ public void testEnrollInNullCourse() {
+ student.enrollInCourse(null);
+ assertNull(student.getCourse(), "Student's course should be null");
+ }
+
+ @Test
+ public void testEnrollInDifferentCourse() {
+ Course course1 = new Course("Java Programming", 999.99);
+ Course course2 = new Course("Data Structures", 1299.99);
+
+ student.enrollInCourse(course1);
+ double course1MoneyAfterFirstEnrollment = course1.getMoney_earned();
+
+ student.enrollInCourse(course2);
+
+ assertEquals(course2, student.getCourse(), "Student should be enrolled in the second course");
+ assertEquals(course1MoneyAfterFirstEnrollment, course1.getMoney_earned(), 0.001,
+ "First course money should remain unchanged");
+ assertEquals(course2.getPrice(), course2.getMoney_earned(), 0.001,
+ "Second course money should increase by course price");
+ }
+
+ @Test
+ public void testToString() {
+ String representation = student.toString();
+ assertTrue(representation.contains(student.getStudentId()));
+ assertTrue(representation.contains(STUDENT_NAME));
+ assertTrue(representation.contains(STUDENT_ADDRESS));
+ assertTrue(representation.contains(STUDENT_EMAIL));
+ assertTrue(representation.contains("Not enrolled"));
+
+ Course course = new Course("Python Programming", 799.99);
+ student.enrollInCourse(course);
+ representation = student.toString();
+ assertTrue(representation.contains(course.getName()));
+ assertFalse(representation.contains("Not enrolled"));
+ }
+}
+
diff --git a/IronSchool/src/test/java/TeacherTest.java b/IronSchool/src/test/java/TeacherTest.java
new file mode 100644
index 00000000..b587c330
--- /dev/null
+++ b/IronSchool/src/test/java/TeacherTest.java
@@ -0,0 +1,50 @@
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+public class TeacherTest {
+
+ @Test
+ public void testConstructor() {
+ String name = "Laura Sánchez";
+ double salary = 4500.0;
+
+ Teacher teacher = new Teacher(name, salary);
+
+ // Verifica que el ID se genere y tenga longitud 8
+ assertNotNull("El ID del profesor no debe ser nulo", teacher.getTeacherId());
+ assertEquals("El ID debe tener 8 caracteres", 8, teacher.getTeacherId().length());
+
+ // Verifica que el nombre y salario se asignen correctamente
+ assertEquals("El nombre debe coincidir", name, teacher.getName());
+ assertEquals("El salario debe coincidir", salary, teacher.getSalary(), 0.001);
+ }
+
+ @Test
+ public void testSetters() {
+ Teacher teacher = new Teacher("Ana Torres", 3800.0);
+
+ teacher.setName("Pedro Gómez");
+ teacher.setSalary(4200.5);
+
+ assertEquals("Nombre actualizado incorrecto", "Pedro Gómez", teacher.getName());
+ assertEquals("Salario actualizado incorrecto", 4200.5, teacher.getSalary(), 0.001);
+ }
+
+ @Test
+ public void testUniqueIds() {
+ Teacher t1 = new Teacher("Carlos", 4000.0);
+ Teacher t2 = new Teacher("María", 4000.0);
+
+ assertNotEquals("Los IDs deben ser únicos", t1.getTeacherId(), t2.getTeacherId());
+ }
+
+ @Test
+ public void testToString() {
+ Teacher teacher = new Teacher("Silvia Ramírez", 5000.0);
+ String output = teacher.toString();
+
+ assertTrue("toString debe incluir el ID", output.contains(teacher.getTeacherId()));
+ assertTrue("toString debe incluir el nombre", output.contains("Silvia Ramírez"));
+ assertTrue("toString debe incluir el salario", output.contains("5000.0"));
+ }
+}