diff --git a/FinalExcercise/src/Models/Course.java b/FinalExcercise/src/Models/Course.java index f48a23f..aef59a4 100644 --- a/FinalExcercise/src/Models/Course.java +++ b/FinalExcercise/src/Models/Course.java @@ -245,7 +245,7 @@ public static void listCoursesFromStudent(University university, Student student List courses = university.getCourses(); int id = student.getId(); String name_student = student.getName(); - System.out.println("Classes in which "+name_student+" is included" ); + System.out.println("Classes in which "+name_student+" is included: " ); for (Course course : courses) { diff --git a/FinalExcercise/src/Models/EducationalCommunity/Professor.java b/FinalExcercise/src/Models/EducationalCommunity/Professor.java index eb7f85d..03f68f3 100644 --- a/FinalExcercise/src/Models/EducationalCommunity/Professor.java +++ b/FinalExcercise/src/Models/EducationalCommunity/Professor.java @@ -55,7 +55,7 @@ public int getExperienceYears() { public static List createProfessors() { List professors = new ArrayList<>(); - Professor professor1 = new Professor("Francisco PĂ©rez",BASE_SALARY,PART_TIME,25,0); + Professor professor1 = new Professor("Francisco Castillo",BASE_SALARY,PART_TIME,25,0); Professor professor2 = new Professor("Marina Ladino",BASE_SALARY,FULL_TIME,45,5); professors.add(professor1); diff --git a/FinalExcercise/src/Models/EducationalCommunity/Student.java b/FinalExcercise/src/Models/EducationalCommunity/Student.java index 778a6a3..fa6d28e 100644 --- a/FinalExcercise/src/Models/EducationalCommunity/Student.java +++ b/FinalExcercise/src/Models/EducationalCommunity/Student.java @@ -112,7 +112,7 @@ public static List askForExistingStudents(University university, String for (Student student: students){ int id_student = student.getId(); for (String id: ids_entered) { - if (id_student == Integer.parseInt(id)) { + if (id_student == Integer.parseInt(id) && !students_chosen.contains(student)) { students_chosen.add(student); } } @@ -141,24 +141,31 @@ public static Object askForInfo(Object university, Scanner scan){ while (!student_entered) { - System.out.println("Enter the name of the student:"); + System.out.println("Enter the bullet number of the student for whom you want to review the enrolled courses: "); scan = new Scanner(System.in); - String entered_student_name = scan.nextLine().trim(); + int entered_student_id ; + List students= ((University) university).getStudents(); - if (entered_student_name.isEmpty()) { - System.out.println("Student name cannot be empty"); - continue; - } + try { + entered_student_id = scan.nextInt(); + + if (entered_student_id <= 0) { + System.out.println("Student id must be greater than zero"); + continue; + } + if(entered_student_id>students.size()){ + System.out.println("Student not found"); + continue; + } - if (entered_student_name.matches("\\d+")) { - System.out.println("Student name cannot consist of only numbers"); + } catch (InputMismatchException e) { + System.out.println("Please enter an integer"); continue; } - List students= ((University) university).getStudents(); for (Student student_registered: students) { - String name_student = student_registered.getName(); - if (name_student.equalsIgnoreCase(entered_student_name)) { + int id_student = student_registered.getId(); + if (id_student==entered_student_id) { student=student_registered; student_entered = true; }