<?php
  class Arvutaja implements Kuvatav{
     protected $arv1, $arv2, $eesliide, $tehe;
	 function __construct($a1, $a2, $eesliide){
	    $this->arv1=$a1;
		$this->arv2=$a2;
		$this->eesliide=$eesliide;
		$this->tehe="+";
		$this->loeSaabuvadAndmed();
	 }
	 function kysiTulemus(){
	    return $this->arv1+$this->arv2;
	 }
	 function kysiHTML(){
	    return "<input type='text' name='{$this->eesliide}_a1txt' 
                   value='$this->arv1'	/> $this->tehe 
		        <input type='text' name='{$this->eesliide}_a2txt'
                   value='$this->arv2'	/>
				<input type='submit' value='=' /> ".$this->kysiTulemus()."<br />";
	 }
	 function loeSaabuvadAndmed(){
	    if(isset($_REQUEST[$this->eesliide."_a1txt"])){
		   $this->arv1=intval($_REQUEST[$this->eesliide."_a1txt"]);
		   $this->arv2=intval($_REQUEST[$this->eesliide."_a2txt"]);
		}
	 }
  }
