<?php
// Copyright Andrew Gilbert
// Class which handles how many input boxes are needed, etc, and prints them to
// the page, depending on how many are wanted.
class design
{
  var $numInputs;
  var $runInfo;
  
  // prints number of inputboxes to satisfy conditions passed to it by user
  // i.e. Number of runs and number of measurements per run.
  function printInputboxes($numRuns, $numMeasurements)
  {
  $i = 1;
  $r = 1;
  $this->numInputs = "<form name=\"getInput\" action=\"index.php\" method=\"post\">";
    while($i <= $numRuns)
    {
    $this->numInputs .= "Run " . $i .":<br>\n";
      while($r <= $numMeasurements)
      {
      $this->numInputs .= "Measurement " . $r . ": <input type=\"text\" name=\"" . $i . ":" . $r . "\"><br>\n";
      $r++;
      }
    $r = 1;
    $this->numInputs .= "<br>\n";
    $i++;
    }
  $this->numInputs .= "<input type=\"hidden\" name=\"numRunsDone\" value=\"" . $numRuns . "\">\n";
  $this->numInputs .= "<input type=\"hidden\" name=\"numMeasurementsDone\" value=\"" . $numMeasurements . "\">\n";
  $this->numInputs .= "<input type=\"submit\" value=\"Submit\"></form><br>";
  echo($this->numInputs);  
  }
  
  // echoes the form to enable user to input data about number of runs 
  // and number of measurements per run.
  function printRunsInfo()
  {
  $this->runInfo = "<form name=\"getRunInfo\" action=\"index.php\" method=\"post\">\n";
  $this->runInfo .= "Number of runs: <input type=\"text\" name=\"numRuns\"><br>\n";
  $this->runInfo .= "Number of measurements per run: <input type=\"text\" name=\"numMeasurements\"><br>\n";
  $this->runInfo .= "Calibration error of stopwatch: <input type=\"text\" name=\"cal1\"><br>\n";
  $this->runInfo .= "Scale reading error of stopwatch: <input type=\"text\" name=\"read1\"><br>\n";
  $this->runInfo .= "Random error (e.g. reaction time ~0.1s): <input type=\"text\" name=\"random1\"><br>\n";
  $this->runInfo .= "<br>\n";
  $this->runInfo .= "Starting length: <input type=\"text\" name=\"startLength\"><br>\n";
  $this->runInfo .= "Increments of decrease: <input type=\"text\" name=\"increments\"><br>\n";
  $this->runInfo .= "Calibration error of ruler: <input type=\"text\" name=\"cal2\"><br>\n";
  $this->runInfo .= "Reading error of ruler: <input type=\"text\" name=\"read2\"><br>\n";
  $this->runInfo .= "Random error: <input type=\"text\" name=\"random2\"><br>\n";
  $this->runInfo .= "<input type=\"submit\" value=\"Submit\"></form>";
  echo($this->runInfo);
  }
  
  function printTable()
  {
  echo("
  <table border=\"1\">\n
  <tr>\n
  <th>Average T</th>\n
  <th>Average T^2</th>\n
  <th>% error in T</th>\n
  <th>% error in T^2</th>\n
  <th>Error in T^2</th>\n
  </tr>\n");
  }
  
  // echos page header
  function printHeader()
  {
  echo("<html>\n
  <head>\n
  <title>Data Calculations</title>\n
  </head>\n
  <body>\n");
  }
  
  // echoes page footer
  function printFooter()
  {
  echo("</body>\n
  </html>");
  }
}


?>