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     */ 
019    package net.sourceforge.pavlov.pluglets.feedback.random;
020    
021    
022    /**
023     * A feedback mode that is generous for right answers and
024     * draconian for wrong answers.  Keeps track of "winning streaks."
025     *
026     * @version $Revision: 1.2 $
027     */
028    public class ExpertFeedbackMode extends DefaultVisualFeedbackMode {
029      protected int nanswered;
030      protected int streak = 0;
031      protected int oldSize = 0;
032    
033      /**
034       * Creates a new <code>ExpertFeedbackMode</code> instance.
035       *
036       */
037      public ExpertFeedbackMode() {
038        super(75, 0, 0, 75);
039        nanswered = 0;
040        size = 75;
041      }
042    
043      /**
044       * Gives an encouraging message.
045       *
046       * @return a <code>String</code> value
047       */
048      public String getMessage() {
049        String msg = "<HTML>";
050    
051        if (streak > 0) {
052          msg += "You are correct!<BR>";
053          msg += "You have gotten " + streak + " right in a row.<BR>";
054          msg += "Increased size from " + oldSize + " to " + size + ".<BR>";
055        } else {
056          msg += "Get one right and I'll show you a picture<BR>";
057          msg += "Decreased size from " + oldSize + " to " + size + ".<BR>";
058        }
059        return msg;
060      }
061    
062      /**
063       * Increments the size, gives bonuses every 15 questions.
064       *
065       */
066      public void rightEvent() {
067        streak++;
068        nanswered++;
069        oldSize = size;
070        size += 35;
071        if ((nanswered % 15) == 0) size = size + 20;
072      }
073    
074      /**
075       * Sets image size to minimum size.  Gives bonuses every 15 questions.
076       *
077       */
078      public void wrongEvent() {
079        streak = 0;
080        oldSize = size;
081        size = minimumSize;
082        if ((nanswered % 15) == 0) size = size + 20;
083        if (size < minimumSize) size = minimumSize;
084      }
085        
086    
087      /**
088       * Gets a menu-friendly name for this mode.
089       *
090       * @return a <code>String</code> value
091       */  
092      public String getShortName() {
093        return "Expert";
094      }
095    
096      /**
097       * Gets a descriptive name for this mode. 
098       *
099       * @return a <code>String</code> value
100       */
101      public String toString() {
102        return "Expert Feedback Mode";
103      }
104    }
105