We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c0fb259 commit 7678e59Copy full SHA for 7678e59
1 file changed
days/13-15 textgames/rps/rps_actors.py
@@ -0,0 +1,31 @@
1
+import random
2
+
3
+class Player:
4
+ def __init__(self, name, score):
5
+ self.name = name
6
+ self.score = score
7
8
+class Roll():
9
+ def __init__(self, roll):
10
+ self.roll = roll
11
12
+ def get_name(self):
13
+ return self.roll
14
15
+ def can_defeat(self, beats):
16
+ # rolls that can be defeated by self
17
+ my_roll = self.get_name()
18
+ their_roll = beats.get_name()
19
+ if my_roll in 'Rock' and their_roll in 'Scissors':
20
+ winner = my_roll
21
+ elif my_roll in 'Scissors' and their_roll in 'Paper':
22
23
+ elif my_roll in 'Paper' and their_roll in 'Rock':
24
25
+ elif my_roll == their_roll:
26
+ winner = "Tie game!"
27
+ else:
28
+ winner = their_roll
29
+ return winner
30
31
0 commit comments