Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Bicycle.php
- class Bicycle
- {
- private $color;
- private $currentSpeed;
- private $nbSeats = 1;
- private $nbWheels = 2;
- public function __construct(string $color, $currentSpeed)
- {
- $this->color= $color;
- $this->currentSpeed=$currentSpeed;
- }
- public function forward()
- {
- $this->currentSpeed = 15;
- return "Go !";
- }
- private function dump()
- {
- var_dump($this);
- }
- public function brake(): string
- {
- $sentence= "";
- while ($this->currentSpeed>0){
- $this->currentSpeed--;
- $sentence .= "Brake !!!";
- }
- $sentence .= "I'm stopped !";
- return $sentence;
- }
- public function getColor(): string{
- return $this->color;
- }
- public function setColor($color)
- {
- $this->color=$color;
- return $this;
- }
- public function getCurrentSpeed():int
- {
- return $this->currentSpeed;
- }
- public function setCurrentSpeed(int $currentSpeed): void
- {
- $this->currentSpeed = $currentSpeed;
- if ($currentSpeed >=0){
- $this->currentSpeed= $currentSpeed;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement