Constructive criticism is required for the 2 methods below. I'm trying to develop better OO skills.
// Set up scanner to allow for searching of modules
public static String searchModule() {
Scanner scan;
System.out.print("Search module code: ");
scan = new Scanner(System.in);
String searchModule = scan.nextLine().trim();
return searchModule;
}
// Search modules and return all students enrolled on it
public static void moduleStudentSearch(Set<Module> modules, Set<Student> students) {
String searchModule = searchModule();
for (Module module : modules) {
if (searchModule.equalsIgnoreCase(module.getName())) {
Iterator it = students.iterator();
while (it.hasNext()) {
Student student = (Student) it.next();
if (student.getModules().contains(module)) {
System.out.printf("%s ", student.getName());
}
}
}
}
}
static
is not OOP. \$\endgroup\$