In this assignment you will extend the work you started in Lab 4 on the club project to include a method that returns the number of members who joined our club in a given month, and a method to purge members who joined our club in a given month and year, returning a collection of those members purged.
Prep
assign3 directory under your cs102 course directory. This is the directory in which you will create your BlueJ project.
assign3 directory: $ cp -r ~/cs102/lab4/ ~/cs102/assign3/
Tasks
For this assignment you will implement and test the challenge exercises for this assignment, as described in the BlueJ project’s README.TXT file.
Define a method in the Club class with the following signature and description:
/** * Return how many members joined in the given month. * @param month The month we are interested in. * @return How many members joined in the given month. */ public int joinedInMonth(int month)
If the month parameter is outside the valid range of 1-12, print an error message and return zero.
Define a method in the Club class with the following signature and description:
/** * Remove from the club's collection all members who joined * in the given month and year, and return them stored in a * separate collection object. * @param month The month of the Membership. * @param year The year of the Membership. * @return A collection of members purged */ public ArrayList<Membership> purge(int month, int year)
If the month parameter is outside the valid range of 1-12, print an error message and return a collection object with no objects stored in it.
Note: the purge method is significantly harder to write than any of the others.
Don’t forget to add tests in your Examples class that test the methods you implemented above.
Once you have completed the above exercises, all the tests you added in your Examples class pass, and your name is in the header comments for all your *.java files:
submit102 script