rangga_hrdme

urutan tidak sesuai

Dec 22nd, 2022
809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | Source Code | 0 0
  1. <?php
  2.  
  3. class Car
  4. {
  5.     // Properties/ variable
  6.     public $merk;
  7.     public $warna;
  8.     public $kecepatan;
  9.  
  10.     // Methods
  11.    public function setMerk(string $merk)
  12.     {
  13.         if (empty($merk)) {
  14.             echo "Salah";
  15.         } else {
  16.         $this->merk = $merk;
  17.         }
  18.     }
  19.  
  20.    public function getMerk(): string
  21.     {
  22.         return sprintf("$this->merk \r\n");
  23.        
  24.     }
  25.  
  26.     public function setWarna(string $warna)
  27.     {
  28.         if (empty($warna)) {
  29.             echo "Salah";
  30.         } else {
  31.         $this->warna = $warna;
  32.         }
  33.     }
  34.  
  35.    public function getWarna(): string
  36.     {
  37.         return sprintf("$this->warna \r\n");
  38.     }
  39.  
  40.     public function setCepat(int $kecepatan)
  41.     {
  42.         if ($kecepatan < 0) {
  43.             echo "0 \r\n";
  44.         } else {
  45.         $this->kecepatan = $kecepatan;
  46.         }
  47.     }
  48.  
  49.    public function getCepat(): string
  50.     {
  51.         return sprintf("$this->kecepatan \r\n");
  52.     }
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment