$30 off During Our Annual Pro Sale. View Details »

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

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

nrs

October 02, 2021
Tweet

More Decks by nrs

Other Decks in Programming

Transcript

  1. View Slide

  2. $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";
    }
    }

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. OOP
    TIPS

    View Slide

  7. OOP
    TIPS

    View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. View Slide

  18. View Slide

  19. View Slide

  20. View Slide

  21. View Slide

  22. View Slide

  23. View Slide

  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
    ================================================================================

    View Slide

  25. View Slide

  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

    View Slide

  27. View Slide

  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.

    View Slide

  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.

    View Slide

  30. View Slide

  31. View Slide

  32. View Slide

  33. View Slide

  34. View Slide

  35. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  39. View Slide

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

    View Slide

  41. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  49. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  55. function crypt_password(string $password)
    {
    return password_hash($password, PASSWORD_DEFAULT);
    }

    View Slide

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

    View Slide

  57. View Slide

  58. View Slide

  59. View Slide

  60. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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;
    }
    }
    }

    View Slide

  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;
    }
    }
    }

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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;
    }
    }
    }

    View Slide

  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;
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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 "敗北";
    }
    }

    View Slide

  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 "敗北";
    }
    }

    View Slide

  79. View Slide

  80. View Slide

  81. View Slide

  82. View Slide

  83. View Slide

  84. OOP
    TIPS

    View Slide

  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 "敗北";
    }
    }

    View Slide

  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 "敗北";
    }
    }

    View Slide

  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 "敗北";
    }
    }

    View Slide

  88. View Slide

  89. View Slide

  90. View Slide

  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 "敗北";
    }
    }

    View Slide

  92. View Slide

  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;
    }
    }
    }

    View Slide

  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;
    }
    }
    }
    }

    View Slide

  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;
    }
    }
    }
    }

    View Slide

  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;
    }
    }
    }
    }

    View Slide

  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;
    }
    }
    }
    }

    View Slide

  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;
    }
    }
    }
    }

    View Slide

  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;
    }
    }
    }
    }

    View Slide

  100. $game = new JankenGame();
    $game->play(1, 2);

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  108. $message = "hello";

    View Slide

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

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  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 "敗北";
    }
    }
    :

    View Slide

  116. View Slide

  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;
    }
    }
    }

    View Slide

  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;
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  120. View Slide

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

    View Slide

  122. View Slide

  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;
    }
    }
    }
    }

    View Slide

  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;
    }
    }
    }
    }

    View Slide

  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";
    }
    }
    }
    }

    View Slide

  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";
    }
    }
    }
    }

    View Slide

  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";
    }
    }
    }
    }

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  131. View Slide

  132. OOP
    TIPS

    View Slide

  133. View Slide

  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";
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  146. View Slide

  147. View Slide

  148. View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  153. View Slide

  154. class JapaneseDisplay {
    function show(int $result) {
    if ($result === 1) {
    echo "勝ち";
    } else if ($result === 0) {
    echo "引き分け";
    } else {
    echo "負け";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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);
    }
    }

    View Slide

  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);
    }
    }

    View Slide

  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);
    }
    }

    View Slide

  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);
    }
    }

    View Slide

  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);
    }
    }

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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 "負け";
    }
    }
    }

    View Slide

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

    View Slide

  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";
    }
    }
    }

    View Slide

  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);
    }

    View Slide

  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);
    }

    View Slide

  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);
    }

    View Slide

  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();
    }
    }

    View Slide

  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();
    }
    }

    View Slide

  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();
    }
    }

    View Slide

  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();
    }
    }

    View Slide

  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();
    }
    }

    View Slide

  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();
    }
    }

    View Slide

  179. View Slide

  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();
    }
    }

    View Slide

  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();
    }
    }

    View Slide

  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();
    }
    }

    View Slide

  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();
    }
    }

    View Slide

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

    View Slide

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

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  200. View Slide

  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);

    View Slide

  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);

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  205. interface DisplayInterface {
    function show(int $result);
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  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";
    }
    }
    }

    View Slide

  209. View Slide

  210. View Slide

  211. OOP
    TIPS

    View Slide

  212. View Slide

  213. View Slide

  214. View Slide

  215. View Slide

  216. View Slide

  217. View Slide

  218. View Slide

  219. View Slide

  220. View Slide

  221. View Slide

  222. View Slide

  223. View Slide

  224. View Slide

  225. View Slide

  226. View Slide

  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);
    }
    :

    View Slide

  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);
    }
    :

    View Slide

  229. interface ResultGateWayInterface
    {
    function save(int $leftHand, int $rightHand, int $result);
    }

    View Slide

  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
    :
    }
    }

    View Slide

  231. OOP
    TIPS

    View Slide

  232. View Slide

  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);
    }
    :
    }

    View Slide

  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);
    }
    :
    }

    View Slide

  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);
    }
    :
    }

    View Slide

  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);
    }
    :
    }

    View Slide

  237. View Slide

  238. View Slide

  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);
    }
    :
    }

    View Slide

  240. interface DisplayInterface
    {
    function win();
    function draw();
    function lose();
    }
    class JapaneseDisplay implements DisplayInterface
    {
    function win()
    {
    echo "勝ち";
    }
    function draw()
    {
    echo "引き分け";
    }
    function lose()
    {
    echo "負け";
    }
    }

    View Slide

  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();
    }

    View Slide

  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();
    }

    View Slide

  243. interface DisplayInterface
    {
    function win();
    function draw();
    function lose();
    }
    class JapaneseDisplay implements DisplayInterface
    {
    function win()
    {
    echo "勝ち";
    }
    function draw()
    {
    echo "引き分け";
    }
    function lose()
    {
    echo "負け";
    }
    }

    View Slide

  244. View Slide

  245. View Slide

  246. View Slide

  247. View Slide

  248. View Slide

  249. View Slide

  250. View Slide

  251. View Slide

  252. View Slide

  253. View Slide

  254. View Slide

  255. View Slide

  256. View Slide

  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;
    }
    }

    View Slide

  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;
    }
    }

    View Slide

  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;
    }
    }

    View Slide

  260. View Slide

  261. View Slide

  262. View Slide

  263. View Slide

  264. View Slide

  265. View Slide

  266. View Slide

  267. View Slide

  268. View Slide

  269. View Slide

  270. View Slide

  271. View Slide

  272. View Slide

  273. View Slide