3. search(String s): Prints all members whose name contain the given string s as a
substring. To check if s is contained in a member, use the library
contains() method as follows:
if ( member.getName().contains(s) ) {
// print member
}
If you use a for-each loop, member would be the for-each variable; if you use a while loop, you will need something like
Membership member = members.get(N);
4. totalDonations(): Returns (not prints) the sum of the donations of all the members. You will need a temporary variable such as sum.
5. Optional, for 1 point of extra credit: write earliestMember(): Prints the member who joined earliest. It is acceptable to print the member with the smallest year of joining, and to ignore ties. This is again done with a loop: you loop through all the elements of members, and keep a running record of minYear, the smallest year of joining seen so far, and also minMember, the member whose year of joining is minYear. (Alternatively, you can keep track of int position, the position in the list of the earliest member, so minMember is members.get(position).)
int minYear = 3000; // initialize to a value >= any valid yearAfter the completion of the loop, you print out minMember, the club member with the given position.
int position = 0; // not used here
Membership minMember = null;
for (Membership m : members) {
if (m joined even earlier than minYear) { // earliest year found so far
minMember = ??;
minYear = ??;
}
}
Email me your completed project. To create a zipfile out of a folder, navigate to the folder in the Windows Explorer (that is, not in BlueJ), right-click on the folder, and select Send To => Compressed (zipped) folder. This should create an ordinary file named <foldername>.zip. Then attach that zipfile to an email to me.