-
-
Save esehara/6893782 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/* オブジェクト指向 | |
* クラス化しただけ | |
*/ | |
echo '広義のオブジェクト指向の中の考えでクラス化って呼ばれる物?'. PHP_EOL; | |
class Kuji { | |
public $is_win; | |
private $WIN_STRING = "当たり"; | |
private $LOOSE_STRING = "外れ"; | |
private function set_win_or_loose() | |
{ | |
$this->is_win = rand(10, 100) > 90; | |
} | |
private function echo_result() | |
{ | |
echo $this->is_win ? $this->WIN_STRING : $this->LOOSE_STRING; | |
echo PHP_EOL; | |
} | |
public function lot() { | |
$this->set_win_or_loose(); | |
$this->echo_result(); | |
} | |
} | |
$takano_kuji = new Kuji(); | |
$esehara_kuji = new Kuji(); | |
$takano_kuji->lot(); | |
$esehara_kuji->lot(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment