Advertisement
Guest User

Untitled

a guest
May 27th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. <?php
  2. interface Rownanie
  3. {
  4. public function wyswietl(Dane $dane);
  5. public function setDane(Dane $dane);
  6. }
  7.  
  8. class Dane implements Rownanie
  9. {
  10. private $in;
  11.  
  12. public function __construct(){
  13. $this->tab[] = 0;
  14. $this->tab[] = 1;
  15. $this->tab[] = 2;
  16. $this->tab[] = 3;
  17. }
  18.  
  19. public function getA(){return $this->tab[0];}
  20. public function getB(){return $this->tab[1];}
  21. public function getC(){return $this->tab[2];}
  22. public function getD(){return $this->tab[3];}
  23.  
  24. public function setDane(Dane $dane){
  25. $dane->tab[0] = -2;
  26. $dane->tab[1] = -3;
  27. $dane->tab[2] = -4;
  28. $dane->tab[3] = -5;
  29. }
  30.  
  31. public function wyswietl(Dane $dane){
  32. if($dane->getA()!=0)echo $dane->getA(),"xx ";
  33.  
  34. if(($dane->getA() == 0 && $dane->getB()!=0) || ($dane->getB()!=0 && $dane->getB()<0))echo $dane->getB(),"x ";
  35. else if($dane->getB()!=0) echo " + " , $dane->getB() , "x";
  36.  
  37. if($dane->getC()!=0 && $dane->getC()<0)echo " " , $dane->getC()," ";
  38. else if($dane->getC()!=0) echo " + ",$dane->getC();
  39.  
  40. if($dane->getD() != 0 && $dane->getD()<0)echo $dane->getD() ,"i";
  41. if($dane->getD() != 0 && $dane->getD()>0)echo " + " , $dane->getD() ,"i";
  42. echo "<br>";
  43. }
  44. }
  45.  
  46. class Delta extends Dane implements Rownanie
  47. {
  48. protected $deltar;
  49. protected $deltau;
  50. protected $cz_rz;
  51. protected $cz_ur;
  52.  
  53. public function __construct()
  54. {
  55. $deltar = 0.0;
  56. $deltau = 0.0;
  57. $cz_rz = 0.0;
  58. $cz_ur = 0.0;
  59. }
  60. public function getCzRz(){return $this->cz_rz;}
  61. public function getCzUR(){return $this->cz_ur;}
  62.  
  63. public function setDane(Dane $dane)
  64. {
  65. $this->deltar = $dane->getB()* $dane->getB() - 4 * $dane->getA() * $dane->getC();
  66. $this->deltau = -4 *$dane->getA()* $dane->getD();
  67.  
  68. $this->cz_rz = sqrt((sqrt(($this->deltar * $this->deltar) + ($this->deltau * $this->deltau)) + $this->deltar)/2);
  69. $this->cz_ur = sqrt((sqrt(($this->deltar * $this->deltar) + ($this->deltau * $this->deltau)) - $this->deltar)/2);
  70. }
  71. public function wyswietl(Dane $dane)
  72. {
  73. if($dane->getA()!=0 && $dane->getD() ==0)
  74. {
  75. echo "Delta = ",$this->deltar, "<br>";
  76. }
  77. if($dane->getA() != 0 && $dane->getD() != 0)
  78. {
  79. if($this->deltau>0)echo "DELTA = ",$this->deltar," + ",$this->deltau ,"i <br>";
  80. if($this->deltau<0)echo "DELTA = ",$this->deltar," ",$this->deltau ,"i <br>";
  81. }
  82. }
  83.  
  84. }
  85.  
  86. class ObliczRownanie extends Delta implements Rownanie
  87. {
  88. protected $x1r,$x2r,$x3r,$x4r;
  89. protected $x1u,$x2u,$x3u,$x4u;
  90.  
  91. public function __construct(){
  92. $this->x1r = 0.0; $this->x2r = 0.0; $this->x3r = 0.0; $this->x4r = 0.0;
  93. $this->x1u = 0.0; $this->x2u = 0.0; $this->x3u = 0.0; $this->x4u = 0.0;
  94. }
  95.  
  96. public function setDane(Dane $dane)
  97. {
  98. echo "ASD";
  99. }
  100. public function wyswietl(Dane $dane)
  101. {
  102. echo "ASD";
  103. }
  104.  
  105. }
  106. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement