Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.4 kB
4
Indexable
Never
 public void searchCandidate(ArrayList<Candidate> candidates, ArrayList<Experience> experience, ArrayList<Internship> internship, ArrayList<Fresher> fresher) {
        printListNameCandidate(candidates, experience, internship, fresher);

        if (candidates.isEmpty() && experience.isEmpty() && internship.isEmpty() && fresher.isEmpty()) {
            System.out.println();
            System.out.println("List empty !!!");
            System.out.println();
        } else {
            System.out.print("Input Candidate name (First name or Last name): ");
            String nameSearch = s.checkInputString();
            System.out.println("EXPERIENCE = 0, FRESHER = 1, INTERNSHIP = 2");
            System.out.print("Input type of candidate: ");
            int typeCandidate = s.checkInputIntLimit(0, 2);

            if (typeCandidate == 0) {
                if (experience.isEmpty()) {
                    System.out.println();
                    System.out.println("No candidate found !!!");
                    System.out.println();
                }
                for (Experience experiences : experience) {
                    if (experiences.getTypeCandidate() == typeCandidate && (experiences.getFirstName().indexOf(nameSearch) >= 0
                            || experiences.getLastName().indexOf(nameSearch) >= 0)) {
                        System.out.println("The candidates found: ");
                        a.displayExperience(experience);
                    } else {
                        System.out.println("No candidate found !!!");
                        break;
                    }

                    break;
                }
            } else if (typeCandidate == 1) {
                if (fresher.isEmpty()) {
                    System.out.println();
                    System.out.println("No candidate found !!!");
                    System.out.println();
                }
                for (Fresher freshers : fresher) {
                    if (freshers.getTypeCandidate() == typeCandidate && freshers.getFirstName().contains(nameSearch)
                            || freshers.getLastName().contains(nameSearch)) {
                        System.out.println("The candidates found: ");
                        a.displayFresher(fresher);
                    } else {
                        System.out.println("No candidate found !!!");
                        break;
                    }
                    break;

                }

            } else {
                if (internship.isEmpty()) {
                    System.out.println();
                    System.out.println("No candidate found !!!");
                    System.out.println();
                }
                for (Internship internships : internship) {
                    if (internships.getTypeCandidate() == typeCandidate && internships.getFirstName().contains(nameSearch)
                            || internships.getLastName().contains(nameSearch)) {
                        System.out.println("The candidates found: ");
                        a.displayInternship(internship);
                    } else {
                        System.out.println("No candidate found !!!");
                        break;
                    }
                    break;

                }

            }

        }
    }