I am writing a program that has a membership class. Each Membership object contains details of a person's name, and the month and year in which
they joined the club. All membership details are filled out when a Membership object is created. Then there is a club class that has a field for an array list, a method that returns the current size of the collection and a join method. I am not sure how to get the join method to compile. Anew Membership object should be added to a Club's objects collection via the Club's objects join method, which has the following
signature and description:

/**
* Add a new member to the club's collection of members.
* @param member The member object to be added.
*/
public void join(Membership member)
e following description

Here is my code for the whole class:

public class Club
{
    // Define any necessary fields here ...
    private ArrayList members;
    
    /**
     * Constructor for objects of class Club
     */
    public Club()
    {
        // Initialise any fields here ...
        members = new ArrayList();
        
    }
     /**
     * Add a new member to the club's list of members.
     * @param member The member object to be added.
     */
    public void join(Membership member)
    {
        members.add(Membership.member);
    }

    /**
     * @return The number of members (Membership objects) in
     *         the club.
     */
    public int numberOfMembers()
    {
        return members.size();
    }
}

Code tags added -Narue

use code tags.
What error are you getting?

Sorry about the code tags, I am new to all this and I don't really know what that means to use code tags. I am getting a cannot find symbol-variable member.
Thanks!!!

>I am getting a cannot find symbol-variable member.
That's because it can't find a definition for the Membership class. I also get an error concerning ArrayList because you neglected to show us what imports you're doing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.