Created
March 25, 2023 10:40
-
-
Save CamKem/adc68f85ef3baeeb52b04527f05cb113 to your computer and use it in GitHub Desktop.
Player Class for Tennis Match Kata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests\Feature\Katas; | |
class Player | |
{ | |
public int $points = 0; | |
public string $name; | |
public function __construct(string $name) | |
{ | |
$this->name = $name; | |
} | |
public function scorePoint(): void | |
{ | |
$this->points++; | |
} | |
public function toScore(): string | |
{ | |
switch($this->points) { | |
case 0: | |
return 'love'; | |
case 1: | |
return 'fifteen'; | |
case 2: | |
return 'thirty'; | |
case 3: | |
return 'forty'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment