SHARE
TWEET

Untitled

a guest Aug 18th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Drink.php
  3.  
  4. // 名前空間の定義
  5. namespace Mochi\MyNamespace;
  6.  
  7. // クラスの定義
  8. class Drink
  9. {
  10.     // メンバ変数
  11.     private $amount = 500;
  12.  
  13.     // コンストラクタ
  14.     public function __construct($a = 500)
  15.     {
  16.         $this->SetAmount($a);
  17.     }
  18.  
  19.     // メソッド
  20.     public function EchoParams()
  21.     {
  22.         echo '残り'.$this->GetAmount().'ml';
  23.     }
  24.  
  25.     // メソッド
  26.     public function GetAmount()
  27.     {
  28.         return $this->amount;
  29.     }
  30.  
  31.     // メソッド
  32.     public function SetAmount($a)
  33.     {
  34.         if(0 <= $a && $a <= 500)
  35.         {
  36.             $this->amount = $a;
  37.         }
  38.         else
  39.         {
  40.             // 何もしない。
  41.         }
  42.     }
  43. }
  44. ?>
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