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