Last active
February 2, 2025 04:19
-
-
Save mkaschenko/89a0c565a96aa8434a51 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Player | |
| attr_reader :name, :turn | |
| def initialize(name, turn) | |
| @name = name | |
| @turn = turn | |
| end | |
| end | |
| class Judge | |
| def winner(player, another_player) | |
| return player if player.turn == another_player.turn | |
| win_rules[player.turn].include?(another_player.turn) | |
| end | |
| def win_rules | |
| { 'rock' => ['scissors'], | |
| 'paper' => ['rock'], | |
| 'scissors' => ['paper'] } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment