/** @author Scott Marshall @author University of Glasgow, MSc IT Project 2001 @author Building an OnLine Course in Computing Fundamentals */ package ukacgla_ATT; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Vector; abstract public class Checker{ /** Allows access to the GUI and student input variables */ protected TableUI table; /** Contains the random numbers corresponding to the type of logic gate */ protected TTRandom random; /** True if all student input correct, otherwise false */ protected boolean correct; /** Holds the number of lines containing errors */ protected Vector wrongLines; public Checker(TableUI t,TTRandom r){ table = t; random = r; wrongLines = new Vector(); } /** Implementations of calcAnswer(int row) must provide the correct answer for a single row. */ abstract protected void calcAnswer(int row); /** Implementations of revealAnswer(int row) will display the correct answer for a single row. */ abstract protected void revealAnswer(int row); /** Implementation of checkAnswer(int row) must check if the student input for a single line is correct.*/ abstract protected void checkAnswer(int row); /** Returns boolean true if no errors found.*/ protected boolean allCorrect() { if (wrongLines.size()==0) correct = true; else correct = false; return correct; } /** Vector wrongLines contains the rows with errors. Method returns the vector as a string to allow table to construct the appropriate error message */ protected String wrongLines(){ return wrongLines.toString(); } /** clears contents of vector prior to next checking run. */ protected void clearVector(){ wrongLines.clear(); } }