<?php include "Transport.php"; include "Car.php"; include "Plane.php"; include "Ship.php"; include "Train.php"; include "Bike.php"; $car = new Car(); $car->go(); $plane = new Plane(); $plane->go(); $train = new Train(); $train->go(); $car = new Ship(); $car->go(); $bike = new Bike(); $bike->go();
<?php include "Models/Bike.php"; include "Models/Car.php"; include "Models/Plane.php"; $minutos = 10; $vehicle = new Bike(); echo $vehicle->getName() . ': </br>'; echo 'velocidad: ' . $vehicle->speed() . '</br>'; echo 'maximo de pasajeros: ' . $vehicle->maxPassengers() . '</br>'; echo 'distancia: ' . $vehicle->travelDistance($minutos) . '</br> </br>'; $vehicle2 = new Car(); echo $vehicle2->getName() . ': </br>'; echo 'velocidad: ' . $vehicle2->speed() . '</br>'; echo 'maximo de pasajeros: ' . $vehicle2->maxPassengers() . '</br>'; echo 'distancia: ' . $vehicle2->travelDistance($minutos) . '</br> </br>'; $vehicle3 = new Plane(); echo $vehicle3->getName() . ': </br>'; echo 'velocidad: ' . $vehicle3->speed() . '</br>'; echo 'maximo de pasajeros: ' . $vehicle3->maxPassengers() . '</br>'; echo 'distancia: ' . $vehicle3->travelDistance($minutos) . '</br> </br>';
echo "-Price: \$" . $this->price . '<br>'; echo "-Max Speed: " . $this->max_speed . ' mph<br>'; echo "-Miles: " . $this->miles . ' mi<br>'; return $this; } public function drive() { echo "*You drive 10 miles across the screen!*<br>"; $this->miles += 10; return $this; } public function reverse() { echo "*You back up 5 miles across the screen!*<br>"; $this->miles -= 5; if ($this->miles < 0) { $this->miles = 0; echo "~OOPS! You backed up too far and hit the wall!~<br>"; } return $this; } } $bike1 = new Bike(600, 60); $bike1->drive()->drive()->drive()->reverse()->displayInfo(); echo "<br>"; $bike2 = new Bike(300, 30); $bike2->drive()->drive()->reverse()->reverse()->displayInfo(); echo "<br>"; $bike3 = new Bike(100, 15); $bike3->reverse()->reverse()->reverse()->displayInfo(); echo "<br>";
class Bike { public $model; public $brand; public $price; public function __construct($m, $b, $p) { $this->model = $m; $this->brand = $b; $this->price = $p; echo "<br>Ստեղծվեց " . __CLASS__ . " տիպի օբյեկտ<br>"; } public function getAllInfo() { echo "<br>Model " . $this->model; echo "<br>Brand " . $this->brand; echo "<br>Price \$" . $this->price; } public function __destruct() { echo "<br>քանդվում է " . $this->model . "<br>"; echo "<br>" . __CLASS__ . " տիպի օբյեկտը քանդվեց<br>"; } } $bmw = new Bike(); $bmw->model = "BMW X6"; $bmw->brand = "Չնխուանդձյու"; $bmw->price = 1000; $bmw->getAllInfo(); $otherBike = new Bike("track", "mmmm", 15000); $otherBike->getAllInfo();
$name = $x->getName(); echo "You can not travel on a " . $name . " whit " . $new_pas . " passengers. The number of allowed passengers for the selected transport is " . $max; } break; case '2': $x = new Car(); $max = $x->maxPassengers(); if ($new_pas <= $max) { echo "You can travel now"; } else { $name = $x->getName(); echo "You can not travel on a " . $name . "whit" . $new_pas . "passengers. The number of alllowed passengers for the selected transport is" . $max; } break; case '3': $x = new Bike(); $max = $x->maxPassengers(); if ($new_pas <= $max) { echo "You can travel now"; } else { $name = $x->getName(); echo "You can not travel on a " . $name . "whit" . $new_pas . "passengers. The number of alllowed passengers for the selected transport is" . $max; } break; } } ?> <!--/body> </html-->
<?php include 'Vehicle.php'; include 'Plane.php'; include 'Car.php'; include 'Bike.php'; $plane = new Plane(); $plane->velocidad(1000); $plane->fly(); $plane->maxpassengers(600); $car = new Car(); $car->velocidad(160); $car->notfly(); $car->maxpassengers(5); $bike = new Bike(); $bike->velocidad(30); $bike->notfly(); $bike->maxpassengers(2);
{ $this->price = $price; $this->max_speed = $max_speed; $this->miles = 0; } //methods public function displayInfo() { echo "hello\n"; echo "{$this->price} , {$this->max_speed}, {$this->miles}."; } public function get_displayInfo() { return $this->property1; } public function reverse() { echo "Reversing"; $this->miles = $this->miles - 5; return $this; } public function drive() { echo "Driving"; $this->miles = $this->miles + 10; return $this; } } $bike1 = new Bike(43, 21); // price and max speed. echo $bike1->drive()->reverse()->drive()->displayInfo();
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { try { $rules = array('first_name' => 'required|min:2|max:20', 'last_name' => 'required|min:2|max:20', 'city' => 'required|max:50', 'pincode' => 'required|between:6,10'); $messages = array('first_name.required' => 'First name is required.', 'last_name.required' => 'Last name is required.', 'city.required' => 'City is required.', 'pincode.required' => 'Pincode is required.'); $validator = Validator::make(Input::all(), $rules, $messages); if ($validator->fails()) { $ers = json_decode($validator->messages()->toJson()); $ermsg = ""; foreach ($ers as $errs) { foreach ($errs as $key => $value) { $ermsg .= $value . "<br/>"; } } return $this->response(array('statusCode' => 400, 'statusDescription' => 'Bad Request', 'errors' => $ermsg)); } else { $uid = Auth::id(); if ($id == $uid) { $user = Auth::user(); $user->fname = Input::get('first_name'); $user->lname = Input::get('last_name'); $user->address = Input::get('address'); $user->colony = Input::get('colony'); $user->area = Input::get('area'); $user->city = Input::get('city'); $user->pincode = Input::get('pincode'); $user->save(); $bike = Bike::where('user_id', '=', $uid)->where('status', '=', 0, 'AND')->orderBy('id', 'desc')->first(); if ($bike) { $unique_id = $user->city . "-" . $user->pincode . "-"; for ($i = 0; $i < 11; $i++) { $unique_id .= rand(0, 9); } $bike->unique_id = $unique_id; $bike->status = 1; $bike->qr_code = base64_encode(QrCode::format('png')->size(150)->encoding('UTF-8')->color(150, 90, 10)->backgroundColor(125, 184, '#808040')->generate($unique_id)); $bike->updatedon = date("Y-m-d H:i:s"); $bike->save(); } return $this->response(array('statusCode' => 100, 'statusDescription' => 'Success', 'data' => $user)); } else { return $this->response(array('statusCode' => 400, 'statusDescription' => "Bad Request", "errors" => "You cannot change profile of others.")); } } } catch (Exception $e) { return $this->response(array('statusCode' => 401, 'statusDescription' => "Bad Request", "errors" => $e->getMessage())); } }
require_once __DIR__ . '/Parking.php'; require_once __DIR__ . '/Parkable.php'; require_once __DIR__ . '/Vehicule.php'; require_once __DIR__ . '/Bike.php'; require_once __DIR__ . '/Car.php'; require_once __DIR__ . '/Plane.php'; require_once __DIR__ . '/Ferry.php'; require_once __DIR__ . '/ConcretMixer.php'; $parking = new Parking(); echo count($parking); // method count de la classe sera appelée $brompton = new Bike('brompton', 'no engine'); $brompton->speed(10); var_dump($brompton); $dahon = new Bike('dahon', 'no engine'); $dahon->speed(10); var_dump($dahon); $zoe = new Car('zoe', 'hydrogen'); $zoe->speed(100); var_dump($zoe); $a320 = new Plane('A380', 'hydrogen'); $a320->speed(900); var_dump($a320); $concretMixer = new ConcretMixer(); var_dump($concretMixer); //$parking->add($a320); // Impossible car non Parkable $parking->add($brompton); var_dump(count($parking)); $parking->add($dahon); var_dump(count($parking));
$errors = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["using"])) { $errors = "Please select one travel option"; } else { $using = $_POST["using"]; if (!empty($using)) { switch ($using) { case 'plane': $vehicle = new Plane(); break; case 'car': $vehicle = new Car(); break; case 'bike': $vehicle = new Bike(); break; } } $passengers = filter_var($_POST["passengers"], FILTER_SANITIZE_NUMBER_INT); if ($passengers != "") { $max = $vehicle->getMaxPassengers(); if ($passengers <= $max) { header("Location: http://192.168.33.10/Day2/success.php"); exit; } else { $errors = "You can't travel on a " . $vehicle->getTypeVehicle() . " with " . $passengers . " passengers. The maximun number of allowed passengers for the selected transport is " . $vehicle->getMaxPassengers() . "."; } } else { $errors = "Please insert a number valid"; }
$this->miles += 10; return $this; } public function reverse() { echo "Reversing...<br>"; $this->miles -= 5; if ($this->miles < 0) { $this->miles = 0; } return $this; } } $bike1 = new Bike(200, "25mph"); $bike2 = new Bike(100, "20mph"); $bike3 = new Bike(250, "40mph"); $bike1->drive(); $bike1->drive(); $bike1->drive(); $bike1->reverse(); $bike1->displayinfo(); echo "<br>"; $bike2->drive(); $bike2->drive(); $bike2->reverse(); $bike2->reverse(); $bike2->displayinfo(); echo "<br>"; $bike3->reverse(); $bike3->reverse(); $bike3->reverse();
{ $this->price = $price; $this->max_speed = $max_speed; $this->miles = 0; } //methods public function displayInfo() { echo "hello\n"; echo "{$this->price} , {$this->max_speed}, {$this->miles}."; } public function get_displayInfo() { return $this->property1; } public function reverse() { echo "Reversing"; $this->miles = $miles - 5; } public function drive() { echo "Driving"; $this->miles = $miles + 10; } } $obj1 = new Bike(43, 21); // price and max speed. echo $obj1->drive(); echo $obj1->reverse(); echo $obj1->displayInfo();