Answer the question
In order to leave comments, you need to log in
What tests can be written for the functionality of creating an object and calling methods?
There is this conditional code in php:
$player1 = new Player('Vasa', new SimpleChoise());
$player2 = new Player('Peta', new RandomChoise());
$game = new Game(new StoneScissorPaperGameStrategy(), $player1, $player2);
$result = [];
for ($i = 0; $i < 10; $i++) {
$winnerName = $game->run();
if(isset($result[$winnerName])) {
$result[$winnerName]++;
} else {
$result[$winnerName] = 1;
}
}
foreach ($result as $player => $value)
{
echo sprintf("\nPlayer %s wins %s times", $player, $value);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question