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 visual feedback mode is a strategy for altering an image
024 * based on a user's correct or incorrect response.
025 *
026 * @version $Revision: 1.3 $
027 */
028 public class DefaultVisualFeedbackMode {
029 /**
030 * The initial size of an image in this mode.
031 *
032 */
033 protected int initialSize;
034 /**
035 * The minimum size of an image in this mode.
036 *
037 */
038 protected int minimumSize;
039 /**
040 * How much the size is increased for a correct response.
041 *
042 */
043 protected int increment;
044 /**
045 * How much the size is decreased for an incorrect response.
046 *
047 */
048 protected int decrement;
049 /**
050 * Current image size.
051 *
052 */
053 protected int size;
054 /**
055 * A descriptive name for this mode.
056 *
057 */
058 protected String name;
059 /**
060 * A message describing how the image was changed in response to the
061 * last answer.
062 *
063 */
064 protected String message;
065
066 /**
067 * Creates a new <code>DefaultVisualFeedbackMode</code> instance.
068 *
069 * @param is an <code>int</code> value
070 * @param inc an <code>int</code> value
071 * @param dec an <code>int</code> value
072 * @param minSz an <code>int</code> value
073 */
074 public DefaultVisualFeedbackMode(final int is, final int inc, final int dec, final int minSz) {
075 initialSize = is;
076 increment = inc;
077 decrement = dec;
078 size = initialSize;
079 minimumSize = minSz;
080 assert initialSize >= minimumSize: "Bad initial size";
081 name = "Unnamed Mode";
082 message = "";
083 }
084
085 // override these for special behaviours
086 /**
087 * Gets the current image size.
088 *
089 * @return an <code>int</code> value
090 */
091 public int getSize() {
092 return size;
093 }
094
095 /**
096 * Sets the current image size. Will not set below the minimum size.
097 *
098 * @param what an <code>int</code> value
099 */
100 public void setSize(final int what) {
101 if (what < minimumSize) size = minimumSize;
102 else size = what;
103 }
104
105 /**
106 * The user answered correctly.
107 *
108 */
109 public void rightEvent() {
110 size = size + increment;
111 }
112
113 /**
114 * The user answered incorrectly.
115 *
116 */
117 public void wrongEvent() {
118 size = size - decrement;
119 if (size < minimumSize) size = minimumSize;
120 }
121
122 /**
123 * Returns this mode's name as a String.
124 *
125 * @return a <code>String</code> value
126 */
127 public String toString() {
128 return name;
129 }
130
131 /**
132 * Set the user-understandable name for the behaviour of this mode.
133 *
134 * @param _n a <code>String</code> value
135 */
136 public void setName(String _n) {
137 name = _n;
138 }
139
140 /**
141 * Return a user-understandable name for the behaviour of this mode.
142 *
143 * @return a <code>String</code> value
144 */
145 public String getShortName() {
146 return "Beginner";
147 }
148
149 /**
150 * Return a message that explains the feedback action taken.
151 *
152 * @return a <code>String</code> value
153 */
154 public String getMessage() {
155 return message;
156 }
157 }
158