Skip to content

Commit 7678e59

Browse files
authored
Create rps_actors.py
1 parent c0fb259 commit 7678e59

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
winner = my_roll
23+
elif my_roll in 'Paper' and their_roll in 'Rock':
24+
winner = my_roll
25+
elif my_roll == their_roll:
26+
winner = "Tie game!"
27+
else:
28+
winner = their_roll
29+
return winner
30+
31+

0 commit comments

Comments
 (0)