Question: L5 (0.6 marks) Add/Update AddStudent method such that: accepts two input values represent the students name and age if the name and/or age are not
L5 (0.6 marks)
- Add/UpdateAddStudentmethod such that:
- accepts two input values represent the studentsnameandage
- if thenameand/orageare not valid, return false
- if the input name already exists in the array liststudents, return false.
- Hint:Use the appropriate loop structure
- If the studentnameandageare valid and the name does not exist in the ArrayListstudents, then:
- Create a new instance of classStudent
- pass the input parametersnameandageto the constructor of classStudent
- add the new instance to the ArrayListstudents
- Add/UpdateAddFacultymethod such that:
- accepts one input value represents the name of the faculties
- if thenameis not valid, return false
- if the input name already exists in the array listfaculties, return false.
- Hint:Use the appropriate loop structure
- If the facultynameis valid and the name does not exist in the ArrayListfaculties, then:
- Create a new instance of classFaculty
- pass the input parameternameto the constructor of classFaculty
- add the new instance to the ArrayListfaculties
L6 (0.6 marks)
- Add/UpdateAddEnrollmentmethod such that:
- It accepts two input parameters: thestudentNameandfacultyName.
- if the array liststudentsdoes not contain a student with the namestudentName, print an error message and return false.
- if thestudentNamecan be found, set a reference to its object
- Student selectedStudent = students.get(i);
- if the array listfacultiesdoes not contain a faculty with the namefacultyName, print an error message and return false.
- if thefacultyNamecan be found, set a reference to its object
- Faculty selectedFaculty = faculties.get(i);
- Create a new instance of theEnrollmentclass, add it to theenrollmentsarraylist, and return true
- Enrollment newEnrol=new Enrollment(selectedStudent, selectedFaculty);
- enrollments.add(newEnrol);
USE INTELLIJ JAVA TO ANSWER
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
