package jmeetup;

import java.util.*;

/**
 * A Proposal in JMeetUp
 *
 * @version 1.0
 * @author  Prof. David Bernstein, James Madison University
 */
public class Proposal
{
    private Hashtable<String,String>   proponents; // Thread safe
    private int                        id;
    private String                     description;


    /**
     * Default Constructor
     */
    public Proposal()
    {
	this(-1, "Default Proposal");
    }

    /**
     * Explicit Value Constructor
     */
    public Proposal(int id, String description)
    {
	this.id = id;
	this.description = description;
	proponents = new Hashtable<String,String>();
    }


    /**
     * Add a new proponent
     *
     * @param proponent   The new proponent
     */
    public void addProponent(String proponent)
    {
	proponents.put(proponent, proponent);
    }


    /**
     * Get the ID of this Proposal
     *
     * @return   The ID
     */
    public int getID()
    {
	return id;
    }


    /**
     * Get all of the proponents for this Proposal
     *
     * @return   The proponents
     */
    public Enumeration<String> getProponents()
    {
	return proponents.elements();
    }


    /**
     * Remove a proponent
     *
     * @param proponent   The proponent to remove
     */
    public void removeProponent(String proponent)
    {
	proponents.remove(proponent);
    }


    /**
     * Return a String representation of this Proposal
     *
     * @return  The String
     */
    public String toString()
    {
	Enumeration<String>  e;
	String       s;

	s = "("+id+") "+description+"\t\t";

	s += "Proponents: ";
	e = proponents.elements();
	while (e.hasMoreElements()) 
        {
	    s += e.nextElement() + "  ";
	}

	return s;
    }
}
