Skip to content

Instantly share code, notes, and snippets.

@esehara
Forked from ugdark/gist:6885982
Last active December 25, 2015 01:19
Show Gist options
  • Save esehara/6893782 to your computer and use it in GitHub Desktop.
Save esehara/6893782 to your computer and use it in GitHub Desktop.
<?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