Hi guys I was just wondering how would I use setters and getters to add values (int) into my two arrays from which I have to calculate the euclidean distance later on in the code. This is what I have so far, I have tried several times and for several hours but the way I tried obviously doesn't work.
abstract class Euclidean
{
protected $pointA=array();
protected $pointB=array();
public function Calculate($pointA, $pointB)
{
$n = count($pointA);
$sum = 0;
for ($i = 0; $i < $n; $i++) {
$sum += ($pointA[$i] - $pointB[$i]) * ($pointA[$i] - $pointB[$i]);
echo sqrt($sum);
}
return sqrt($sum);
}
public function setpointA($x)
{
$this->pointA = $x;
}
public function getpointA()
{
return $this->pointA;
}
public function setpointB($y)
{
$this->pointB = $y;
}
public function getpointB()
{
return $this->pointB;
}
}
UPDATE
public function setpointA($pointA)
{
parent::setpointA($pointA=1&&3&&9&&2);
}
public function getPointA()
{
return $this->pointA;
}
public function setpointB($pointB)
{
parent::setpointB($pointB=7&&2&&3&&9);
}
public function getpointB()
{
return parent::getpointB();
}
Comments
Post a Comment