Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define(U1, 10);
- class Machine {
- public $name;
- public $model;
- public $price;
- public $maxpassagers;
- public function setName($name) {
- $this->name = $name;
- }
- public function getName() {
- return $this->name;
- }
- public function setModel($model) {
- $this->model = $model;
- }
- public function getModel() {
- return $this->model;
- }
- public function setPrice($price) {
- $this->price = $price;
- }
- public function getPrice() {
- return $this->price;
- }
- public function setMaxpassagers($maxpassagers) {
- $this->maxpassagers = $maxpassagers;
- }
- public function getMaxpassagers() {
- return $this->maxpassagers;
- }
- }
- class Cars extends Machine {
- }
- class Bus extends Machine {
- }
- class Moto extends Machine {
- }
- $product3 = new Bus();
- $product3->setName('Honda');
- $product3->setModel('Giorno');
- $product3->setPrice(5);
- $product3->setMaxpassagers(1);
- $product4 = new Cars();
- $product4->setName('WV');
- $product4->setModel('B5');
- $product4->setPrice(12);
- $product4->setMaxpassagers(4);
- if( ( $product3->getPrice() ) <= U1) {
- $need = U1 - $product3->getPrice();
- echo
- '<h4><b>'.$product3->getName().'</b> is good for you.';
- if ($need > 0)
- echo ' You save: <b>'.$need.'$</b><br></h4>';
- }
- else{
- $need = $product3->getPrice() - U1;
- echo '<b>'.$product3->getName().'</b> is bad for you. You need <b>'.$need.'$</b><br>';
- }
- if( ( $product4->getPrice() ) <= U1) {
- $need = U1 - $product4->getPrice();
- echo
- '<h4><b>'.$product4->getName().'</b> is good for you.';
- if ($need > 0)
- echo ' You save: <b>'.$need.'$</b><br></h4>';
- }
- else{
- $need = $product4->getPrice() - U1;
- echo '<b>'.$product4->getName().'</b> is bad for you. You need <b>'.$need.'$</b><br>';
- }
- ?>
Add Comment
Please, Sign In to add comment