Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHPで学ぶオブジェクト指向プログラミング入門 / Introduction to OOP with PHP

E37b4344ef4bfd0fc4826c04971e54fb?s=47 nrs
October 02, 2021

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

E37b4344ef4bfd0fc4826c04971e54fb?s=128

nrs

October 02, 2021
Tweet

Transcript

  1. None
  2. <?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"; } }
  3. None
  4. None
  5. None
  6. OOP TIPS

  7. OOP TIPS

  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. None
  15. None
  16. None
  17. None
  18. None
  19. None
  20. None
  21. None
  22. None
  23. None
  24. 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 ================================================================================
  25. None
  26. 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
  27. None
  28. 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.
  29. 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.
  30. None
  31. None
  32. None
  33. None
  34. None
  35. None
  36. $a = 3; $b = 5; $c = $a +

    $b;
  37. $a = 3; $b = 5; $c = $a +

    $b;
  38. $a = 3; $b = 5; $c = $a +

    $b;
  39. None
  40. $a = 0b0011; $b = 0b0101; $c = $a +

    $b;
  41. None
  42. $bottom = 3; $height = 6; $area = $bottom *

    $height / 2;
  43. $bottom = 3; $height = 6; $area = $bottom *

    $height / 2;
  44. $bottom = 3; $height = 6; $area = $bottom *

    $height / 2;
  45. $bottom = 3; $height = 6; $area = $bottom *

    $height / 2;
  46. $bottom = 3; $height = 6; $area = $bottom *

    $height / 2;
  47. $bottom = 3; $height = 6; $area = $bottom *

    $height / 2;
  48. $bottom = 3; $height = 6; $area = $bottom *

    $height / 2;
  49. None
  50. $area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {

    return $bottom * $height / 2; }
  51. $area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {

    return $bottom * $height / 2; }
  52. $area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {

    return $bottom * $height / 2; }
  53. $area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {

    return $bottom * $height / 2; }
  54. $area = calculate_area_of_triangle(3, 6); function calculate_area_of_triangle(int $bottom, int $height) {

    return $bottom * $height / 2; }
  55. function crypt_password(string $password) { return password_hash($password, PASSWORD_DEFAULT); }

  56. function crypt_password(string $password) { return password_hash($password, PASSWORD_DEFAULT, ["cost" => 12]);

    }
  57. None
  58. None
  59. None
  60. None
  61. function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);

    show_result($result); }
  62. function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);

    show_result($result); }
  63. function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);

    show_result($result); }
  64. function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);

    show_result($result); }
  65. function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);

    show_result($result); }
  66. 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; } } }
  67. 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; } } }
  68. function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);

    show_result($result); }
  69. function play(int $left_hand, int $right_hand) { $result = judge($left_hand, $right_hand);

    show_result($result); }
  70. function show_result(int $result) { if ($result === 1) { echo

    "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } }
  71. function show_result(int $result) { if ($result === 1) { echo

    "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } }
  72. 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; } } }
  73. 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; } } }
  74. 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"; } } }
  75. 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"; } } }
  76. 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"; } } }
  77. 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 "敗北"; } }
  78. 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 "敗北"; } }
  79. None
  80. None
  81. None
  82. None
  83. None
  84. OOP TIPS

  85. 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 "敗北"; } }
  86. 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 "敗北"; } }
  87. 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 "敗北"; } }
  88. None
  89. None
  90. None
  91. 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 "敗北"; } }
  92. None
  93. 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; } } }
  94. 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; } } } }
  95. 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; } } } }
  96. 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; } } } }
  97. 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; } } } }
  98. 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; } } } }
  99. 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; } } } }
  100. $game = new JankenGame(); $game->play(1, 2);

  101. $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 "敗北"; } } :
  102. $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 "敗北"; } } :
  103. $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 "敗北"; } } :
  104. $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 "敗北"; } } :
  105. $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 "敗北"; } } :
  106. $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 "敗北"; } } :
  107. $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 "敗北"; } } :
  108. $message = "hello";

  109. $message = "hello"; $message = new String(['h', 'e', 'l', 'l',

    'o'])
  110. $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 "敗北"; } } :
  111. $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 "敗北"; } } :
  112. $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 "敗北"; } } :
  113. $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 "敗北"; } } :
  114. $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 "敗北"; } } :
  115. $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 "敗北"; } } :
  116. None
  117. 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; } } }
  118. 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; } } }
  119. 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"; } } }
  120. None
  121. function showResult(int $result) { if ($result === 1) { echo

    "勝利"; } else if ($result === 0) { echo "引き分け"; } else { echo "敗北"; } }
  122. None
  123. 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; } } } }
  124. 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; } } } }
  125. 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"; } } } }
  126. 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"; } } } }
  127. 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"; } } } }
  128. class JankenGame { function play(int $leftHand, int $rightHand) { $game

    = new JankenGame(); $game->play(1, 2);
  129. class JankenGame { function play(int $leftHand, int $rightHand) { $game

    = new JankenGame(); $game->play(1, 2);
  130. class JankenGame { function play(int $leftHand, int $rightHand) { $game

    = new JankenGame(); $game->play(1, 2);
  131. None
  132. OOP TIPS

  133. None
  134. 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"; } }
  135. 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"; } } }
  136. 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"; } } }
  137. 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"; } } }
  138. 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"; } } }
  139. 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"; } } }
  140. 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"; } } }
  141. 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"; } } }
  142. 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"; } } }
  143. 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"; } } }
  144. 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"; } } }
  145. 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"; } } }
  146. None
  147. None
  148. None
  149. 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"; } } }
  150. 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"; } } }
  151. 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"; } } }
  152. 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"; } } }
  153. None
  154. class JapaneseDisplay { function show(int $result) { if ($result ===

    1) { echo "勝ち"; } else if ($result === 0) { echo "引き分け"; } else { echo "負け"; } } }
  155. 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"; } } }
  156. 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); } }
  157. 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); } }
  158. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); $display->show($result); } else { $display = new EnglishDisplay(); $display->show($result); } }
  159. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); $display->show($result); } else { $display = new EnglishDisplay(); $display->show($result); } }
  160. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); $display->show($result); } else { $display = new EnglishDisplay(); $display->show($result); } }
  161. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); }
  162. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); }
  163. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); }
  164. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); }
  165. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); }
  166. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); }
  167. 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 "負け"; } } }
  168. class JankenGame { : function showResult(int $result, string $lang) {

    if ($lang === "ja") { $display = new JapaneseDisplay(); } else { $display = new EnglishDisplay(); } $display->show($result); }
  169. 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"; } } }
  170. 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); }
  171. 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); }
  172. 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); }
  173. 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(); } }
  174. 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(); } }
  175. 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(); } }
  176. 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(); } }
  177. 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(); } }
  178. 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(); } }
  179. None
  180. 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(); } }
  181. 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(); } }
  182. 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(); } }
  183. 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(); } }
  184. class JankenGame { function __construct($display) { $this->display = $display; }

    function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); }
  185. class JankenGame { function __construct($display) { $this->display = $display; }

    function play(int $leftHand, int $rightHand) { $result = $this->judge($leftHand, $rightHand); $this->display->show($result); }
  186. 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);
  187. 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);
  188. 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);
  189. 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);
  190. 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);
  191. 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);
  192. 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);
  193. 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);
  194. 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);
  195. $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);
  196. $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);
  197. $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);
  198. 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);
  199. 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);
  200. None
  201. 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);
  202. 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);
  203. 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"; } } }
  204. 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"; } } }
  205. interface DisplayInterface { function show(int $result); }

  206. 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"; } } }
  207. 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"; } } }
  208. 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"; } } }
  209. None
  210. None
  211. OOP TIPS

  212. None
  213. None
  214. None
  215. None
  216. None
  217. None
  218. None
  219. None
  220. None
  221. None
  222. None
  223. None
  224. None
  225. None
  226. None
  227. 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); } :
  228. 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); } :
  229. interface ResultGateWayInterface { function save(int $leftHand, int $rightHand, int $result);

    }
  230. 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 : } }
  231. OOP TIPS

  232. None
  233. 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); } : }
  234. 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); } : }
  235. 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); } : }
  236. 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); } : }
  237. None
  238. None
  239. 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); } : }
  240. interface DisplayInterface { function win(); function draw(); function lose(); }

    class JapaneseDisplay implements DisplayInterface { function win() { echo "勝ち"; } function draw() { echo "引き分け"; } function lose() { echo "負け"; } }
  241. 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(); }
  242. 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(); }
  243. interface DisplayInterface { function win(); function draw(); function lose(); }

    class JapaneseDisplay implements DisplayInterface { function win() { echo "勝ち"; } function draw() { echo "引き分け"; } function lose() { echo "負け"; } }
  244. None
  245. None
  246. None
  247. None
  248. None
  249. None
  250. None
  251. None
  252. None
  253. None
  254. None
  255. None
  256. None
  257. 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; } }
  258. 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; } }
  259. 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; } }
  260. None
  261. None
  262. None
  263. None
  264. None
  265. None
  266. None
  267. None
  268. None
  269. None
  270. None
  271. None
  272. None
  273. None