Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <?php
  2.  
  3. //Bicycle.php
  4. class Bicycle
  5. {
  6. private $color;
  7.  
  8. private $currentSpeed;
  9.  
  10. private $nbSeats = 1;
  11.  
  12. private $nbWheels = 2;
  13.  
  14. public function __construct(string $color, $currentSpeed)
  15. {
  16. $this->color= $color;
  17. $this->currentSpeed=$currentSpeed;
  18. }
  19.  
  20. public function forward()
  21. {
  22.  
  23. $this->currentSpeed = 15;
  24. return "Go !";
  25.  
  26. }
  27. private function dump()
  28. {
  29. var_dump($this);
  30.  
  31. }
  32.  
  33.  
  34. public function brake(): string
  35. {
  36. $sentence= "";
  37. while ($this->currentSpeed>0){
  38. $this->currentSpeed--;
  39. $sentence .= "Brake !!!";
  40. }
  41. $sentence .= "I'm stopped !";
  42. return $sentence;
  43. }
  44.  
  45. public function getColor(): string{
  46. return $this->color;
  47. }
  48.  
  49.  
  50. public function setColor($color)
  51. {
  52. $this->color=$color;
  53. return $this;
  54. }
  55.  
  56. public function getCurrentSpeed():int
  57. {
  58. return $this->currentSpeed;
  59. }
  60.  
  61. public function setCurrentSpeed(int $currentSpeed): void
  62. {
  63. $this->currentSpeed = $currentSpeed;
  64. if ($currentSpeed >=0){
  65. $this->currentSpeed= $currentSpeed;
  66. }
  67. }
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement