SHARE
TWEET

Untitled

a guest Nov 12th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class Car
  4. {
  5.     private $model;
  6.     private $engines;
  7.     private $weight;
  8.     private $color;
  9.  
  10.     public function __construct(string $model, Engine $engines, string $weight, string $color)
  11.     {
  12.         $this->model = $model;
  13.         $this->engines = $engines;
  14.         $this->weight = $weight;
  15.         $this->color = $color;
  16.     }
  17.  
  18.     public function getModel(): string
  19.     {
  20.         return $this->model;
  21.     }
  22.  
  23.     public function getEngine(): Engine
  24.     {
  25.         return $this->engines;
  26.     }
  27.  
  28.     public function getWeight(): string
  29.     {
  30.         return $this->weight;
  31.     }
  32.  
  33.     public function getColor(): string
  34.     {
  35.         return $this->color;
  36.     }
  37.  
  38. }
  39.  
  40. class Engine
  41. {
  42.     private $model;
  43.     private $power;
  44.     private $displacement;
  45.     private $efficiency;
  46.  
  47.     public function __construct(string $model, int $power, string $displacement, string $efficiency)
  48.     {
  49.         $this->model = $model;
  50.         $this->power = $power;
  51.         $this->displacement = $displacement;
  52.         $this->efficiency = $efficiency;
  53.     }
  54.  
  55.     public function getModel(): string
  56.     {
  57.         return $this->model;
  58.     }
  59.  
  60.     public function getPower(): int
  61.     {
  62.         return $this->power;
  63.     }
  64.  
  65.     public function getDisplacement(): string
  66.     {
  67.         return $this->displacement;
  68.     }
  69.  
  70.     public function getEfficiency(): string
  71.     {
  72.         return $this->efficiency;
  73.     }
  74.  
  75. }
  76.  
  77. $carList = [];
  78. $engineList = [];
  79. $n = intval(readline());
  80. while ($n-- > 0) {
  81.     $input = explode(" ", readline());
  82.     $model = $input[0];
  83.     $power = intval($input[1]);
  84.     if (count($input) == 4) {
  85.         $displacement = $input[2];
  86.         $efficency = $input[3];
  87.     } else if (count($input) == 3) {
  88.         try {
  89.             $displacement = "n/a";
  90.             $efficency = $input[2];
  91.         } catch (Exception $e) {
  92.             $displacement = $input[2];
  93.             $efficency = "n/a";
  94.         }
  95.     }
  96.     $engines = new Engine($model, $power, $displacement, $efficency);
  97.     $engineList[] = $engines;
  98. }
  99. $m = intval(readline());
  100. while ($m-- > 0) {
  101.     $input = explode(" ", readline());
  102.     $model = $input[0];
  103.     $engineName = $input[1];
  104.     if (count($input) == 4) {
  105.         $weight = $input[2];
  106.         $color = $input[3];
  107.     } else if (count($input) == 3) {
  108.         try {
  109.             $weight = "n/a";
  110.             $color = $input[2];
  111.         } catch (Exception $e) {
  112.             $weight = $input[2];
  113.             $color = "n/a";
  114.         }
  115.     }
  116.     if (key_exists($engineName, $engineList)) {
  117.         $current = '';
  118.     }
  119.     $carsCurrent = new Car($model, $engineName, $weight, $color);
  120.     $carList[] = $carsCurrent;
  121. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top