Closed ivanmoore closed 1 year ago
I understand why you wanted to fix this. Unfortunately I didn't want it fixed :-) This is supposed to be legacy code. The player name problem is deliberate.
I hope you had fun working on this exercise in any case. Thankyou for taking the time to send a pull request.
No worries. Sorry I reached the conclusion that it was intended to be a pure refactoring exercise because the README says "You should not need to change the tests", and version number 4 of the Java and Kotlin ones doesn't have this bug, and none of the python versions do. Should they all be consistently wrong and maybe should "You should not need to change the tests" be removed from the README?
good point about the README. I'll have to check the python version
This is for the Java code only.
Three of the TennisGame implementations use hardcoded Strings "player1" and "player2" to check which player is playing. This means that those classes only give the correct results if the player names happen to be "player1" and "player2" - which they are in the tests but I believe it is not the intention that only those names should give the correct results.
This change is to make those implementations use the player names which the TennisGame was created with, so they work correctly with any player names.
The test has been updated to introduce randomness in the player names in order to show that the scoring works correctly regardless of the names. The randomness does not introduce any non-determinism.