001    /* PAVLOV -- Multiple Choice Study System
002     * Copyright (C) 2000 - 2004 T.J. Willis
003     * 
004     * This program is free software; you can redistribute it and/or
005     * modify it under the terms of the GNU General Public License
006     * as published by the Free Software Foundation; either version 2
007     * of the License, or (at your option) any later version.
008     *      
009     * This program is distributed in the hope that it will be useful,
010     * but WITHOUT ANY WARRANTY; without even the implied warranty of
011     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012     * GNU General Public License for more details.
013     *          
014     * You should have received a copy of the GNU General Public License
015     * along with this program; if not, write to the Free Software
016     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
017     *  
018     * $Header: /cvsroot/pavlov/net/sourceforge/pavlov/user/AbstractStrategy.java,v 1.6 2004/07/01 09:03:43 tj_willis Exp $
019     */ 
020    package net.sourceforge.pavlov.user;
021    import java.awt.event.*;
022    import java.util.*;
023    
024    import net.sourceforge.pavlov.pluglets.*;
025    import net.sourceforge.pavlov.main.standalone.ResourceBroker;
026    import org.apache.log4j.*;
027    
028    /**
029     * <code>AbstractStrategy</code> is the base class for a 
030     * question selection strategy.
031     *
032     * @author <a href="mailto:tj_willis@users.sourceforge.net"> T.J. Willis </a>
033     * @version $Revision: 1.6 $
034     */
035    public abstract class AbstractStrategy implements Pluglet
036    {
037      /**
038       * List of questions to choose from.
039       */
040        protected Collection<QuestionData> questions;
041        protected ResourceBroker rb;
042    
043     
044      /**
045       * Creates a new <code>AbstractStrategy</code> instance with
046       * no QuestionData to work on.
047       */
048        public AbstractStrategy()
049        {
050                rb = ResourceBroker.getInstance();
051        }
052    
053        /**
054         * Creates a new <code>AbstractStrategy</code> instance to
055         * draw from the given Questions.
056         *
057         */
058        public AbstractStrategy(final Collection<QuestionData> questions)
059        {
060            this();
061            setQuestions(questions);
062        }
063    
064    
065        /**
066         * Set the collection of questions to draw from.
067         *
068         */
069        public void setQuestions(final Collection<QuestionData> questions)
070       {
071           /* if(this.questions!=null){
072               this.questions.clear();
073               }*/
074           this.questions =questions;
075       }
076    
077    
078       /**
079       * Returns a short descriptive name for this strategy.  Override
080       * this method to name your strategy.
081       * @return a <code>String</code> value
082       */   
083        public String getName()
084        {
085            return "Unnamed Strategy";
086        }
087        
088    
089    
090      /**
091       * Returns the next question using the implemented strategy.
092       *
093       * @return a <code>QuestionData</code> value
094       */
095        public abstract QuestionData getQuestion(Vector<QuestionData> exclusion);
096       
097        /**
098         * Describe <code>actionPerformed</code> method here.
099         *
100         * @param e an <code>ActionEvent</code> value
101         */
102        public void actionPerformed(ActionEvent e) {}
103        
104    }
105    
106