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     * A feedback mode that is less generous than Expert for right answers
023     * and less harsh for wrong answers.
024     * old college try.
025     *
026     * @version $Revision: 1.2 $
027     */
028    public class IntermediateFeedbackMode extends DefaultVisualFeedbackMode {
029      private int nanswered;
030      private int oldSize;
031      private boolean right;
032    
033      /**
034       * Creates a new <code>IntermediateFeedbackMode</code> instance.
035       *
036       */
037      public IntermediateFeedbackMode() {
038        super(150, 0, 0, 150);
039        nanswered = 0;
040        size = 150;
041      }
042    
043      /**
044       * Increments the size, gives bonuses every 10 questions.
045       *
046       */
047      public void rightEvent() {
048        right = true;
049        nanswered++;
050        oldSize = size;
051        size += 25;
052        if ((nanswered % 10) == 0) size = size + 20;
053      }
054    
055      /**
056       * Decrements image size for a wrong answer.
057       *
058       */
059      public void wrongEvent() {
060        right = false;
061        oldSize = size;
062        size -= 50;
063        if ((nanswered % 10) == 0) size = size + 20;
064        if (size < minimumSize) size = minimumSize;
065      }
066    
067    
068      /**
069       * Gives an encouraging message.
070       *
071       * @return a <code>String</code> value
072       */
073      public String getMessage() {
074        if (nanswered != 0) {
075          if (right) {
076            message = "Good Job!<BR>";
077          } else {
078            message = "Keep pluggin'!!<BR>";
079          }
080          if ((nanswered % 5) == 0)
081            message += "<B>Bonus awarded +20</B>";
082          if ((nanswered % 25) == 0)
083            message += "<B>Special Bonus awarded +50</B>";
084        }
085        return message;
086      }
087    
088      /**
089       * Gets a menu-friendly name for this mode.
090       *
091       * @return a <code>String</code> value
092       */
093      public String getShortName() {
094        return "Intermediate";
095      }
096    
097      /**
098       * Gets a descriptive name for this mode. 
099       *
100       * @return a <code>String</code> value
101       */
102      public String toString() {
103        return "Intermediate Feedback Mode";
104      }
105    }
106