fork(1) download
  1. <?php
  2. class Point {
  3. private $x=0;
  4. private $y=0;
  5. public function setPoint($x,$y){
  6. $this->x=$x;
  7. $this->y=$y;
  8. }
  9. public function showPoint(){
  10. echo "(", $this->x,",", $this->y,")\n";
  11. }
  12. }
  13. class Line {
  14. private $p1;
  15. private $p2;
  16. public function setLine($p1,$p2){
  17. $this->p1=$p1;
  18. $this->p2=$p2;
  19. }
  20. public function showLine(){
  21. $this->p1->showPoint();
  22. $this->p2->showPoint();
  23. }
  24. }
  25. $p1=$p2=new Point;
  26. $p1->setPoint(5, 8);
  27. $p2->setPoint(1, 2);
  28. $l=new Line;
  29. $l->setLine($p1, $p2);
  30. $l->showLine();
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
(1,2)
(1,2)