Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- interface Rownanie
- {
- public function wyswietl(Dane $dane);
- public function setDane(Dane $dane);
- }
- class Dane implements Rownanie
- {
- private $in;
- public function __construct(){
- $this->tab[] = 0;
- $this->tab[] = 1;
- $this->tab[] = 2;
- $this->tab[] = 3;
- }
- public function getA(){return $this->tab[0];}
- public function getB(){return $this->tab[1];}
- public function getC(){return $this->tab[2];}
- public function getD(){return $this->tab[3];}
- public function setDane(Dane $dane){
- $dane->tab[0] = -2;
- $dane->tab[1] = -3;
- $dane->tab[2] = -4;
- $dane->tab[3] = -5;
- }
- public function wyswietl(Dane $dane){
- if($dane->getA()!=0)echo $dane->getA(),"xx ";
- if(($dane->getA() == 0 && $dane->getB()!=0) || ($dane->getB()!=0 && $dane->getB()<0))echo $dane->getB(),"x ";
- else if($dane->getB()!=0) echo " + " , $dane->getB() , "x";
- if($dane->getC()!=0 && $dane->getC()<0)echo " " , $dane->getC()," ";
- else if($dane->getC()!=0) echo " + ",$dane->getC();
- if($dane->getD() != 0 && $dane->getD()<0)echo $dane->getD() ,"i";
- if($dane->getD() != 0 && $dane->getD()>0)echo " + " , $dane->getD() ,"i";
- echo "<br>";
- }
- }
- class Delta extends Dane implements Rownanie
- {
- protected $deltar;
- protected $deltau;
- protected $cz_rz;
- protected $cz_ur;
- public function __construct()
- {
- $deltar = 0.0;
- $deltau = 0.0;
- $cz_rz = 0.0;
- $cz_ur = 0.0;
- }
- public function getCzRz(){return $this->cz_rz;}
- public function getCzUR(){return $this->cz_ur;}
- public function setDane(Dane $dane)
- {
- $this->deltar = $dane->getB()* $dane->getB() - 4 * $dane->getA() * $dane->getC();
- $this->deltau = -4 *$dane->getA()* $dane->getD();
- $this->cz_rz = sqrt((sqrt(($this->deltar * $this->deltar) + ($this->deltau * $this->deltau)) + $this->deltar)/2);
- $this->cz_ur = sqrt((sqrt(($this->deltar * $this->deltar) + ($this->deltau * $this->deltau)) - $this->deltar)/2);
- }
- public function wyswietl(Dane $dane)
- {
- if($dane->getA()!=0 && $dane->getD() ==0)
- {
- echo "Delta = ",$this->deltar, "<br>";
- }
- if($dane->getA() != 0 && $dane->getD() != 0)
- {
- if($this->deltau>0)echo "DELTA = ",$this->deltar," + ",$this->deltau ,"i <br>";
- if($this->deltau<0)echo "DELTA = ",$this->deltar," ",$this->deltau ,"i <br>";
- }
- }
- }
- class ObliczRownanie extends Delta implements Rownanie
- {
- protected $x1r,$x2r,$x3r,$x4r;
- protected $x1u,$x2u,$x3u,$x4u;
- public function __construct(){
- $this->x1r = 0.0; $this->x2r = 0.0; $this->x3r = 0.0; $this->x4r = 0.0;
- $this->x1u = 0.0; $this->x2u = 0.0; $this->x3u = 0.0; $this->x4u = 0.0;
- }
- public function setDane(Dane $dane)
- {
- echo "ASD";
- }
- public function wyswietl(Dane $dane)
- {
- echo "ASD";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement