ArrayList
a) Write the ClubMembers constructor ClubMembers
, which takes one parameters, which contains the names of new club members to be added. The method initialize the memberList by adding all new members. The names can be added in any order. All members added are initially in good standing and share the same graduation year, gradYear, which is 2026.
public ClubMembers(String[] names)
b) Write the ClubMembers method addMembers
, which takes two parameters. The first parameter is a String array containing the names of new club members to be added. The second parameter is the graduation year of all the new club members. The method adds the new members to the memberList instance variable. The names can be added in any order. All members added are initially in good standing and share the same graduation year, gradYear.
Complete the addMembers method.
public void addMembers(String[] names, int gradYear)
c) Write the ClubMembers method count
, to return the number of students who gradated in a specific year.
public int count(int gradYear)
d) Write the ClubMembers method removeMembers, which takes the following actions. Returns a list of all students who have graduated and are in good standing. A member has graduated if the member’s graduation year is less than or equal to the method’s year parameter. If no members meet these criteria, an empty list is returned.
Removes from memberList all members who have graduated, regardless of whether or not they are in good standing.
public ArrayList<MemberInfo> removeMembers(int year)
Last updated