Question
Tasks (Java Code) 1a) Develop the 'University' class shell (i.e. the class body and its attributes) 1b) Develop a setter for each attribute. Each setter
Tasks (Java Code)
1a) Develop the 'University' class shell (i.e. the class body and its attributes)
1b) Develop a setter for each attribute. Each setter must return true if the provided value is valid; false otherwise
1c) Develop a getter for each attribute
1d) Develop a zero parameter constructor. You must initialize all the instance variables with some values. Hint: Don't forget to use the setters to set the values.
1e) Develop a two-parameter constructor for universityName and worldRank.
1f) Develop a method called 'addStudent(String)' that adds the input string, which is a student name, to the list of students (students ArrayList). The method must not accept duplication in the students' names.
1g) Develop a method called 'addFaculty(String)' that adds the input string, which is a faculty name, to the list of faculties (faculties ArrayList). The method must not accept duplication in the faculties' names.
1h) Develop a boolean method 'isStudent(String)' that takes as input a string represents a student name and returns true if it exists in the list of students; false otherwise
1i) Develop a boolean method 'isFaculty(String)' that takes as input a string represents a faculty name and returns true if it exists in the list of faculties; false otherwise
1j) Develop a method name ('addEnrollment') that takes two strings to represent a student name and a faculty. If the student name and the faculty are available (i.e. isStudent and isFaculty return true), then add the enrollment as 'studentname|facultyname' as shown above.
1k) Develop a toStirng method that returns the list of students, faculties and enrollments.
1l) Develop a method called 'countStudentsFaculty(String)' that takes as input a faculty name and returns an integer number that represents how many students enrolled in the that faculty. For example, if the enrollment ArrayList contains ["John|FIT", "Tim|Law", "Emma|FIT"] and the input to the method is "FIT" then the method must return 2.
1m) Develop the main method that creates an instance of the university class, adds students and faculty, adds enrollments, and tests the method 'countStudentsFaculty'.
INSTANCE VARIABLE DESCRIPTION EXAMPLE university Name at least 3 characters Monash,RMIT worldRank a positive non-zero integer 1,304,57 faculties An ArrayList of strings that represents the list of faculties. The minimum length of each string is 3 characters. ["FIT","LAW"] students An ArrayList of strings, where each string represents a student name. ["John,"Tim,"Emma,"Sally"] The minimum length of each string is 2 characters. enrollment An ArrayList of strings, where each string must have two segments separate by l. The first segment represents the student name and the second segment represents the faculty ["John|FIT,Tim Law,Emma FIT] name
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started