/**
 * This is the abstract_Equation class.  It is an abstract class that 
 * defines the common elements among all classes that are equations.
 */
function PrtEquation() {
  this.strEquationType = "Abstract";
  this.hshData = null;
  // Methods: 
  this.getRawResults    = Equation_getRawResults;
  this.priFormatResults = Equation_priFormatResults;
  // Enables constructor to be invoked as an object method to complete object inheritance.
  this.Equation      = Equation;
}

Equation.prototype = new PrtEquation();

/**
 * This is the constructor for the Equation class.
 * @objGraph      The graph that the equation is to be drawn on.
 * @objInputForm  The input form widget, source of the data needed to evaluate an equation.
 * @objTextDisplay The widget that displays the solution set in non-graphical (text) form.
 */
function Equation(objGraph, objInputForm, objTextDisplay) {
  this.objGraph = objGraph;
  this.objInputForm = objInputForm;
  this.objTextDisplay = objTextDisplay;
}


/**
 * This method must be overridden by every concrete class. 
 * It performs the computation that is specific to the equation implemented.
 * @return  this.arrRawResults  The array containing all the x,y result pairs of the solution set.
 */
function Equation_getRawResults() {
  this.hshData = this.objInputForm.getData();
  this.arrRawResults = new Array();
  var strDisplay = "<br><hr>Show the parameters that have been solved for here."; 
  this.objTextDisplay.display(strDisplay+this.priFormatResults());
  return this.arrRawResults;
}


// - - - - - - - - -  Private methods:
/**
 * This method formats the data in this.arrRawResults for output to the 
 * text display widget.
 * @return string  A string containing the HTML to display the above.
 */
function Equation_priFormatResults() {
  var anyI;
  var arrFormattedRawResults = new Array();
  // Array-growth is used here in this critical block for speed optimization.
  for (var intI=0; intI<this.arrRawResults.length; intI++) {
    arrFormattedRawResults[arrFormattedRawResults.length] = "<br>Point #"+intI+": (x: ";
    arrFormattedRawResults[arrFormattedRawResults.length] = this.arrRawResults[intI].intX;
    arrFormattedRawResults[arrFormattedRawResults.length] = "; y: ";
    for (anyI in this.arrRawResults[intI].hshY) {
      arrFormattedRawResults[arrFormattedRawResults.length] = this.arrRawResults[intI].hshY[anyI] + " ";
    }
    arrFormattedRawResults[arrFormattedRawResults.length] = ")";
  }
  return (arrFormattedRawResults.join("")); 
}
