ukacgla_BinaryConverter
Class Checker
java.lang.Object
|
+--ukacgla_BinaryConverter.Checker
- public class Checker
- extends java.lang.Object
Checker class function is to check student input, and determine if correct or not
Method Summary |
protected java.lang.String |
calcAnswer()
calcAnswer() calculates the the correct answer. |
protected int |
calcPower(int b,
int n)
Returns b to the power n (providing b is non negative integer). |
protected boolean |
verifyAnswer()
verifyAnswer() is used to get the students input, and compare it to
the String generated by calcAnswer(). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Checker
public Checker(ConverterFrame f)
calcAnswer
protected java.lang.String calcAnswer()
- calcAnswer() calculates the the correct answer.
It works by :
1. Getting the number to be calculated from the ConverterFrameObject.
2. Creating a new StringBuffer.
3. Calculating the number using the smart power algorithmn used in the
calcPower() method, and building the StringBuffer as the answer.
The StringBuffer is then returned as a string for use in comparison.
calcPower
protected int calcPower(int b,
int n)
- Returns b to the power n (providing b is non negative integer).
This uses a smart power algorithmn to quickly calculate the maximum value
for any number to the power of another number.
verifyAnswer
protected boolean verifyAnswer()
- verifyAnswer() is used to get the students input, and compare it to
the String generated by calcAnswer().
verifyAnswer() checks the specifed line (defined in the answerRow variable) in the studentAnswer table.
The method begins checking at Column Index 1 to skip the labels in Column 0.