Share
Embed
PHPで学ぶオブジェクト指向プログラミング入門 / Introduction to OOP with PHP
PHP Conference Japan 2021 で発表した「PHPで学ぶオブジェクト指向プログラミング入門」のスライドです。
# URL
PHP Conference Japan 2021: https://phpcon.php.gr.jp/2021/
CfP: https://fortee.jp/phpcon-2021/proposal/868cc3d1-114d-4543-a59f-e068b0fb8fa5
YouTube: https://www.youtube.com/c/narusemi
HomePage: https://nrslib.com
Twitter: https://twitter.com/nrslib
nrs
October 02, 2021
Transcript
273 slides
-
<?php $profile = new Profile(); $profile->present(); class Profile { public
function present() { echo "Name:"; echo " 成瀬 允宣"; echo "Job:"; echo " プログラマ"; echo "Achievement:"; echo " PHP Conference 2019:" . " 思想と理想の果てに -- クリーンアーキテクチャのWEBフレームワークを作ろう"; echo " PHP Conference 2020:" . " PHP WEBアプリケーション設計入門――10年先を見据えて作る"; echo " Object-Oriented Conference 2020:" . " keynote: Object-Oriented Diversity"; } } -
SYMBOL NAMES: 1: _main 2: _@2 3: _printf ================================================================================ SECTION
SIZE = 0x00000015; NAME = .text DEFINED SYMBOLS: name = _main offset = 0x00000000; type = 0x0020; class = 0x0002 00000000: 55 push ebp 00000001: 89 E5 mov ebp,esp 00000003: 68 00 00 00 00 push offset _@2 00000008: E8 00 00 00 00 call _printf 0000000D: 59 pop ecx 0000000E: B8 00 00 00 00 mov eax,0 00000013: C9 leave 00000014: C3 ret near ================================================================================ SECTION SIZE = 0x0000000E; NAME = .data 00000000: 48 65 6C 6C 6F 20 57 6F 72 6C 64 2E 0A 00 Hello World... DEFINED SYMBOLS: name = _@2 offset = 0x00000000; type = 0x0000; class = 0x0003 ================================================================================ -
section .data msg db "Hello world!" section .text global _start
_start: mov rax, 1 mov rdi, 1 mov rsi, msg mov rdx, 12 syscall mov rax, 60 mov rdi, 0 syscall -
000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. SAMPLE-01. 000030* 000040 ENVIRONMENT DIVISION.
000050* 000060 DATA DIVISION. 000070* 000080 PROCEDURE DIVISION. 000090 MAIN. 000100 DISPLAY "Hello world!" UPON CONSOLE. 000110 STOP RUN. -
000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. SAMPLE-01. 000030* 000040 ENVIRONMENT DIVISION.
000050* 000060 DATA DIVISION. 000070* 000080 PROCEDURE DIVISION. 000090 MAIN. 000100 DISPLAY "Hello world!" UPON CONSOLE. 000110 STOP RUN. -
$bottom = 3; $height = 6; $area = $bottom *
$height / 2; -
$bottom = 3; $height = 6; $area = $bottom *
$height / 2; -
$bottom = 3; $height = 6; $area = $bottom *
$height / 2; -
$bottom = 3; $height = 6; $area = $bottom *
$height / 2; -
$bottom = 3; $height = 6; $area = $bottom *
$height / 2; -
$bottom = 3; $height = 6; $area = $bottom *
$height / 2; -
$bottom = 3; $height = 6; $area = $bottom *
$height / 2; -
$area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {
return $bottom * $height / 2; } -
$area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {
return $bottom * $height / 2; } -
$area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {
return $bottom * $height / 2; } -
$area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {
return $bottom * $height / 2; } -
$area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {
return $bottom * $height / 2; } -
function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);
show_result($result); } -
function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);
show_result($result); } -
function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);
show_result($result); } -
function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);
show_result($result); } -
function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);
show_result($result); } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return -1; } else if ($right_hand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($right_hand === 2) { // Goo return 1; } else if ($right_hand === 1) { // Choki return -1; } else { //Par return 0; } } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return -1; } else if ($right_hand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($right_hand === 2) { // Goo return 1; } else if ($right_hand === 1) { // Choki return -1; } else { //Par return 0; } } } -
function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);
show_result($result); } -
function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);
show_result($result); } -
function show_result(int $result) { if ($result === 1) { echo
"勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } -
function show_result(int $result) { if ($result === 1) { echo
"勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return -1; } else if ($right_hand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($right_hand === 2) { // Goo return 1; } else if ($right_hand === 1) { // Choki return -1; } else { //Par return 0; } } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return -1; } else if ($right_hand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($right_hand === 2) { // Goo return 1; } else if ($right_hand === 1) { // Choki return -1; } else { //Par return 0; } } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return "draw"; } else if ($right_hand === 1) { // Choki return "win"; } else { //Par return "lose"; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return "lose"; } else if ($right_hand === 1) { // Choki return "draw"; } else { //Par return "win"; } } else { // Par if ($right_hand === 2) { // Goo return "win"; } else if ($right_hand === 1) { // Choki return "lose"; } else { //Par return "draw"; } } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return "draw"; } else if ($right_hand === 1) { // Choki return "win"; } else { //Par return "lose"; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return "lose"; } else if ($right_hand === 1) { // Choki return "draw"; } else { //Par return "win"; } } else { // Par if ($right_hand === 2) { // Goo return "win"; } else if ($right_hand === 1) { // Choki return "lose"; } else { //Par return "draw"; } } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return "draw"; } else if ($right_hand === 1) { // Choki return "win"; } else { //Par return "lose"; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return "lose"; } else if ($right_hand === 1) { // Choki return "draw"; } else { //Par return "win"; } } else { // Par if ($right_hand === 2) { // Goo return "win"; } else if ($right_hand === 1) { // Choki return "lose"; } else { //Par return "draw"; } } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return "draw"; } else if ($right_hand === 1) { // Choki return "win"; } else { //Par return "lose"; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return "lose"; } else if ($right_hand === 1) { // Choki return "draw"; } else { //Par return "win"; } } else { // Par if ($right_hand === 2) { // Goo return "win"; } else if ($right_hand === 1) { // Choki return "lose"; } else { //Par return "draw"; } } } function show_result(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return "draw"; } else if ($right_hand === 1) { // Choki return "win"; } else { //Par return "lose"; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return "lose"; } else if ($right_hand === 1) { // Choki return "draw"; } else { //Par return "win"; } } else { // Par if ($right_hand === 2) { // Goo return "win"; } else if ($right_hand === 1) { // Choki return "lose"; } else { //Par return "draw"; } } } function show_result(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return -1; } else if ($right_hand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($right_hand === 2) { // Goo return 1; } else if ($right_hand === 1) { // Choki return -1; } else { //Par return 0; } } } function show_result(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return -1; } else if ($right_hand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($right_hand === 2) { // Goo return 1; } else if ($right_hand === 1) { // Choki return -1; } else { //Par return 0; } } } function show_result(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return -1; } else if ($right_hand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($right_hand === 2) { // Goo return 1; } else if ($right_hand === 1) { // Choki return -1; } else { //Par return 0; } } } function show_result(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } function show_result(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } -
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand);
$this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
$game = new JankenGame(); $game->play(1, 2); class JankenGame { function
play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } : -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return -1; } else if ($right_hand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($right_hand === 2) { // Goo return 1; } else if ($right_hand === 1) { // Choki return -1; } else { //Par return 0; } } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return 0; } else if ($right_hand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return -1; } else if ($right_hand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($right_hand === 2) { // Goo return 1; } else if ($right_hand === 1) { // Choki return -1; } else { //Par return 0; } } } -
function judge(int $left_hand, int $right_hand) { if ($left_hand === 0)
{ // Goo if ($right_hand === 0) { // Goo return "draw"; } else if ($right_hand === 1) { // Choki return "win"; } else { //Par return "lose"; } } else if ($left_hand === 1) { // Choki if ($right_hand === 0) { // Goo return "lose"; } else if ($right_hand === 1) { // Choki return "draw"; } else { //Par return "win"; } } else { // Par if ($right_hand === 2) { // Goo return "win"; } else if ($right_hand === 1) { // Choki return "lose"; } else { //Par return "draw"; } } } -
function showResult(int $result) { if ($result === 1) { echo
"勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return "draw"; } else if ($rightHand === 1) { // Choki return "win"; } else { //Par return "lose"; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return "lose"; } else if ($rightHand === 1) { // Choki return "draw"; } else { //Par return "win"; } } else { // Par if ($rightHand === 2) { // Goo return "win"; } else if ($rightHand === 1) { // Choki return "lose"; } else { //Par return "draw"; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return "draw"; } else if ($rightHand === 1) { // Choki return "win"; } else { //Par return "lose"; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return "lose"; } else if ($rightHand === 1) { // Choki return "draw"; } else { //Par return "win"; } } else { // Par if ($rightHand === 2) { // Goo return "win"; } else if ($rightHand === 1) { // Choki return "lose"; } else { //Par return "draw"; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $result
= $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === "win") { echo "勝利"; } else if ($result === "draw") { echo "引き分け"; } else { echo "敗北"; } } function judge(int $leftHand, int $rightHand) { if ($leftHand === 0) { // Goo if ($rightHand === 0) { // Goo return "draw"; } else if ($rightHand === 1) { // Choki return "win"; } else { //Par return "lose"; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return "lose"; } else if ($rightHand === 1) { // Choki return "draw"; } else { //Par return "win"; } } else { // Par if ($rightHand === 2) { // Goo return "win"; } else if ($rightHand === 1) { // Choki return "lose"; } else { //Par return "draw"; } } } } -
class JankenGame { function play(int $leftHand, int $rightHand) { $game
= new JankenGame(); $game->play(1, 2); -
class JankenGame { function play(int $leftHand, int $rightHand) { $game
= new JankenGame(); $game->play(1, 2); -
class JankenGame { function play(int $leftHand, int $rightHand) { $game
= new JankenGame(); $game->play(1, 2); -
function judge(int $leftHand, int $rightHand) { if ($leftHand === 0)
{ // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } class JankenGame { function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } -
function judge(int $leftHand, int $rightHand) { if ($leftHand === 0)
{ // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } class JankenGame { function play(int $leftHand, int $rightHand, string $lang) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
function judge(int $leftHand, int $rightHand) { if ($leftHand === 0)
{ // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } class JankenGame { function play(int $leftHand, int $rightHand, string $lang) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
function judge(int $leftHand, int $rightHand) { if ($leftHand === 0)
{ // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } class JankenGame { function play(int $leftHand, int $rightHand, string $lang) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
function judge(int $leftHand, int $rightHand) { if ($leftHand === 0)
{ // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } class JankenGame { function play(int $leftHand, int $rightHand, string $lang) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
function judge(int $leftHand, int $rightHand) { if ($leftHand === 0)
{ // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } class JankenGame { function play(int $leftHand, int $rightHand, string $lang) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
function judge(int $leftHand, int $rightHand) { if ($leftHand === 0)
{ // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } class JankenGame { function play(int $leftHand, int $rightHand, string $lang) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
function judge(int $leftHand, int $rightHand) { if ($leftHand === 0)
{ // Goo if ($rightHand === 0) { // Goo return 0; } else if ($rightHand === 1) { // Choki return 1; } else { //Par return -1; } } else if ($leftHand === 1) { // Choki if ($rightHand === 0) { // Goo return -1; } else if ($rightHand === 1) { // Choki return 0; } else { //Par return 1; } } else { // Par if ($rightHand === 2) { // Goo return 1; } else if ($rightHand === 1) { // Choki return -1; } else { //Par return 0; } } } } class JankenGame { function play(int $leftHand, int $rightHand, string $lang) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
function showResult(int $result, string $lang) { if ($lang === "ja")
{ if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else if ($lang === "en") { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } else if ($lang === "ch") { if ($result === 1) { echo "你赢了"; } else if ($result === 0) { echo "平局"; } else { echo "你失败了"; } } else if ($lang === "fr") { if ($result === 1) { echo "Vous gagnez"; } else if ($result === 0) { echo "Dessiner"; } else { echo "Tu perds"; } } else { if ($result === 1) { echo "Du gewinnst"; } else if ($result === 0) { echo "Zeichnen"; } else { echo "Du verlierst"; } } } -
function showResult(int $result, string $lang) { if ($lang === "ja")
{ if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else if ($lang === "en") { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } else if ($lang === "ch") { if ($result === 1) { echo "你赢了"; } else if ($result === 0) { echo "平局"; } else { echo "你失败了"; } } else if ($lang === "fr") { if ($result === 1) { echo "Vous gagnez"; } else if ($result === 0) { echo "Dessiner"; } else { echo "Tu perds"; } } else { if ($result === 1) { echo "Du gewinnst"; } else if ($result === 0) { echo "Zeichnen"; } else { echo "Du verlierst"; } } } -
function showResult(int $result, string $lang) { if ($lang === "ja")
{ if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else if ($lang === "en") { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } else if ($lang === "ch") { if ($result === 1) { echo "你赢了"; } else if ($result === 0) { echo "平局"; } else { echo "你失败了"; } } else if ($lang === "fr") { if ($result === 1) { echo "Vous gagnez"; } else if ($result === 0) { echo "Dessiner"; } else { echo "Tu perds"; } } else { if ($result === 1) { echo "Du gewinnst"; } else if ($result === 0) { echo "Zeichnen"; } else { echo "Du verlierst"; } } } -
function showResult(int $result, string $lang) { if ($lang === "ja")
{ if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else if ($lang === "en") { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } else if ($lang === "ch") { if ($result === 1) { echo "你赢了"; } else if ($result === 0) { echo "平局"; } else { echo "你失败了"; } } else if ($lang === "fr") { if ($result === 1) { echo "Vous gagnez"; } else if ($result === 0) { echo "Dessiner"; } else { echo "Tu perds"; } } else { if ($result === 1) { echo "Du gewinnst"; } else if ($result === 0) { echo "Zeichnen"; } else { echo "Du verlierst"; } } } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { if ($result === 1) { echo "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } } else { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JapaneseDisplay { function show(int $result) { if ($result ===
1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } -
class JapaneseDisplay { function show(int $result) { if ($result ===
1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class EnglishDisplay { function show(int $result) { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JapaneseDisplay { function show(int $result) { if ($result ===
1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class EnglishDisplay { function show(int $result) { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } class JankenGame { : function showResult(int $result, string $lang) { if ($lang === "ja") { $display = new JapaneseDisplay(); $display->show($result); } else { $display = new EnglishDisplay(); $display->show($result); } } -
class JapaneseDisplay { function show(int $result) { if ($result ===
1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class EnglishDisplay { function show(int $result) { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } class JankenGame { : function showResult(int $result, string $lang) { if ($lang === "ja") { $display = new JapaneseDisplay(); $display->show($result); } else { $display = new EnglishDisplay(); $display->show($result); } } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); $display->show($result); } else { $display = new EnglishDisplay(); $display->show($result); } } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); $display->show($result); } else { $display = new EnglishDisplay(); $display->show($result); } } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); $display->show($result); } else { $display = new EnglishDisplay(); $display->show($result); } } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } class JapaneseDisplay { function show(int $result) { if ($result === 1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { : function showResult(int $result, string $lang) {
if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } class EnglishDisplay { function show(int $result) { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $this->showResult($result, $lang); } function showResult(int $result, string $lang) { if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function play(int $leftHand, int $rightHand, string $lang)
{ $result = $this->judge($leftHand, $rightHand); $display = $this->getDisplay($lang); $display->show($result); } function getDisplay(string $lang) { if ($lang === "ja") { return new JapaneseDisplay(); } else { return new EnglishDisplay(); } } -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
$display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2);
$display = new EnglishDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new ChineseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
$display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2);
$display = new EnglishDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new ChineseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
$display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2);
$display = new EnglishDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new ChineseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new EnglishDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new ChineseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new EnglishDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new ChineseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new EnglishDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new ChineseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand $this->display->show($result); } $display = new JapaneseDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new EnglishDisplay(); $game = new JankenGame($display); $game->play(1, 2); $display = new ChineseDisplay(); $game = new JankenGame($display); $game->play(1, 2); -
class JapaneseDisplay { function show(int $result) { if ($result ===
1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class EnglishDisplay { function show(int $result) { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JapaneseDisplay { function show(int $result) { if ($result ===
1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class EnglishDisplay { function show(int $result) { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JapaneseDisplay implements DisplayInterface { function show(int $result) { if
($result === 1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class EnglishDisplay implements DisplayInterface { function show(int $result) { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JapaneseDisplay implements DisplayInterface { function show(int $result) { if
($result === 1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class EnglishDisplay implements DisplayInterface { function show(int $result) { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JapaneseDisplay implements DisplayInterface { function show(int $result) { if
($result === 1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class EnglishDisplay implements DisplayInterface { function show(int $result) { if ($result === 1) { echo "win"; } else if ($result === 0) { echo "draw"; } else { echo "lose"; } } } -
class JankenGame { function __construct($display, $resultGateWay) { $this->display = $display;
$this->resultGateWay = $resultGateWay; } function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); $this->resultGateWay->save($leftHand, $rightHand, $result); } : -
class JankenGame { function __construct($display, $resultGateWay) { $this->display = $display;
$this->resultGateWay = $resultGateWay; } function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); $this->resultGateWay->save($leftHand, $rightHand, $result); } : -
class DebugResultGateWay implements ResultGateWayInterface { function save(int $leftHand, int $rightHand,
int $result) { echo "leftHand:" . $leftHand . ",rightHand:" . $rightHand . ",result:" . $result; } } class ProductionResultGateWay implements ResultGateWayInterface { function save(int $leftHand, int $rightHand, int $result) { // ... save to database : } } -
class JapaneseDisplay implements DisplayInterface { function show(int $result) { if
($result === 1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class JankenGame { function __construct($display) { $this->display = $display; } function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } : } -
class JapaneseDisplay implements DisplayInterface { function show(int $result) { if
($result === 1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class JankenGame { function __construct($display) { $this->display = $display; } function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } : } -
class JapaneseDisplay implements DisplayInterface { function show(int $result) { if
($result === 1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class JankenGame { function __construct($display) { $this->display = $display; } function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } : } -
class JapaneseDisplay implements DisplayInterface { function show(int $result) { if
($result === 1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class JankenGame { function __construct($display) { $this->display = $display; } function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } : } -
class JapaneseDisplay implements DisplayInterface { function show(int $result) { if
($result === 1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } } class JankenGame { function __construct($display) { $this->display = $display; } function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); } : } -
interface DisplayInterface { function win(); function draw(); function lose(); }
class JapaneseDisplay implements DisplayInterface { function win() { echo "勝ち"; } function draw() { echo "引き分け"; } function lose() { echo "負け"; } } -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { $this->display->win(); } else if ($result === 0) { $this->display->draw(); } else { $this->display->lose(); } } : } interface DisplayInterface { function win(); function draw(); function lose(); } -
class JankenGame { function __construct($display) { $this->display = $display; }
function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->showResult($result); } function showResult(int $result) { if ($result === 1) { $this->display->win(); } else if ($result === 0) { $this->display->draw(); } else { $this->display->lose(); } } : } interface DisplayInterface { function win(); function draw(); function lose(); } -
interface DisplayInterface { function win(); function draw(); function lose(); }
class JapaneseDisplay implements DisplayInterface { function win() { echo "勝ち"; } function draw() { echo "引き分け"; } function lose() { echo "負け"; } } -
class ModelNumber { private string $model; private string $branch; private
string $lot; /** * ModelNumber constructor. */ public function __construct(string $model, string $branch, string $lot) { $this->model = $model; $this->branch = $branch; $this->lot = $lot; } public function toString() { return $this->model . "-" . $this->branch . "-" . $this->lot; } } -
class ModelNumber { private string $model; private string $branch; private
string $lot; /** * ModelNumber constructor. */ public function __construct(string $model, string $branch, string $lot) { $this->model = $model; $this->branch = $branch; $this->lot = $lot; } public function toString() { return $this->model . "-" . $this->branch . "-" . $this->lot; } } -
class ModelNumber { private string $model; private string $branch; private
string $lot; /** * ModelNumber constructor. */ public function __construct(string $model, string $branch, string $lot) { $this->model = $model; $this->branch = $branch; $this->lot = $lot; } public function toString() { return $this->model . "-" . $this->branch . "-" . $this->lot; } }