| Jean Pierre Daviau 2006-09-21, 7:58 am |
| Hi,
I would like the catch exception to exit the process when a division by 0
occurs:
<?
//derive math exception from base class
class arcLengthException extends Exception {
public $type = "";
public $file = __FILE__;
public $line = __LINE__;
public function __construct($type){
parent::__construct($type);
//get filename and line number
$this->type = $type;
}
}
class arcLength extends arcLengthException{
public $e;
public $f;
public $g;
public $h;
public $i;
public $j;
private $arguments;
public function __construct($argv)
{
parent::__construct("arcLength");
//settype($argv(1), "integer");
$this->e = $argv[1];
$this->f = $argv[2];
$this->g = $argv[3];
$this->h = $argv[4];
$this->i = $argv[5];
$this->j = $argv[6];
$this->arguments = $argv;
}
function destroy($id)
{
return 0;
}
function bxcyPerpendiculaires($k, $l, $m, $n, $pente, $c){
$x = ($k+$m)/2; $y = ($l+$n)/2;
$y = (1/$pente) * $x;
$texte = "\n\n--\n";
$y = ((1/$pente) * $x) + 528.725;
$texte = $texte . $y . "\n";
$texte = $texte . $c . "\n";
$texte = $texte . $y . "\n";
echo $texte . "\n--\n\n";
}
function bxcySegments($k, $l, $m, $n){
$texte = "\n\n--\n";
// if(($m-$k) != 0) $pente= ($n-$l)/($m-$k);
try{
$pente= ($n-$l)/($m-$k);
}catch(arcLengthException $e){
//we caught some other type of exception
exit ("Caught exception in " .
$e->file() . " on line " .
$e->line() . "<br>\n");
}
$texte = $texte . $pente . "\n";
$c= $l - ($k*$pente);
$texte = $texte . $c . "\n";
$y = ($pente*$k) + $c;
$texte = $texte . $y . "\n";
echo $texte . "\n--\n\n";
$this->bxcyPerpendiculaires($k, $l, $m, $n, $pente, $c);
}
function main(){
print "- ";
print_r ($this->arguments);
print " -";
$this->bxcySegments($this->e, $this->f, $this->g, $this->h);
$this->bxcySegments($this->g, $this->h, $this->i, $this->j);
$this->bxcySegments($this->e, $this->f, $this->i, $this->j);
}
}
$R = new arcLength($argv);
$R->main();
//php -check-f arc.php 0 10 10 10 20 15
?>
--
Thanks for your attention.
Jean Pierre Daviau
--
Easyphp1.8 with Apache1.3.24
Server version: Apache/2.0.55
Server built: Oct 9 2005 19:16:56
DEVC++, borland 5.5
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
Processor Radeon7000 0x5159 agp
http://www.jeanpierredaviau.com
|