Home‎ > ‎ICT Programming‎ > ‎Java‎ > ‎

BlueJ - Club Project

The Club Project

The Club project simulates managing the memberships at a sport or social club. The Membership class is complete and handles information about club memberships. Your task will be to complete the Club class.

Activity 1

  • Copy the club project to your working folder, unzip it and open it in BlueJ.
  • Open the Club class and observe the missing code. Add code for the following:
    • You'll need to store memberships in a variable-length collection (ArrayList). Create the ArrayList variable. You will need to import the java.util package.
    • Create the actual ArrayList in the constructor of the Club class.
    • Add code to the join method to add a Membership object to the collection.
    • Modify the code in the numberOfMembers method so that it returns the actual number of members in the club.
    • Add a method called showMembers that displays, on the terminal window, all the members in the club. You will need to look at the Membership class to find out which method you can invoke for this. While you're at it. list all the methods of the Membership class.
  • Test your code thoroughly.

In this series of exercises, you will review the methods of the ArrayList class.

Assignment:

  • Write a method (also called showMembers) that will show all the members who joined during a given year. Your method will accept an integer parameter for the year.
  • Write a method called removeMembers which will accept two integer parameters: a month and a year. This method will remove from the club membership all members who joined the club before the given month. For example, removeMembers(1,2011) will remove all members who joined the club before January 1, 2011.
  • Add an array of String objects called monthNames that holds the names of the twelve months of the year. Modify both the showMembers methods so that they display the name of the month rather than the number of the month.
  • Write a method called sortMembers that will sort the members list by the date they joined the club ... longest standing members first.
Comments