Created
August 6, 2019 13:52
-
-
Save kusa-mochi/c67b4a1c3d0679310f6ee431374645a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Soda.php | |
| // 名前空間の定義 | |
| namespace Mochi\MyNamespace; | |
| // 外部ファイルのインポート | |
| require_once 'Drink.php'; | |
| // クラスの継承 | |
| class Soda extends Drink | |
| { | |
| // メンバ変数 | |
| private $gasLevel = 100; | |
| // コンストラクタ | |
| public function __construct($g = 100) | |
| { | |
| parent::__construct(); | |
| $this->SetGasLevel($g); | |
| } | |
| // メソッド | |
| public function EchoParams() | |
| { | |
| parent::EchoParams(); | |
| echo ', ガスレベル:'.$this->GetGasLevel().'%'; | |
| } | |
| // メソッド | |
| public function GetGasLevel() | |
| { | |
| return $this->gasLevel; | |
| } | |
| // メソッド | |
| public function SetGasLevel($g) | |
| { | |
| if(0<= $g && $g <= 100) | |
| { | |
| $this->gasLevel = $g; | |
| } | |
| else | |
| { | |
| // 何もしない。 | |
| } | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment