-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkata.py
45 lines (40 loc) · 2.13 KB
/
kata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class TennisGame():
def __init__(self,server_current_score,receiver_current_score):
self.server_current_score = server_current_score
self.receiver_current_score = receiver_current_score
def add_score(self,point_winner):
# point_winner = 0 --> server wins the point
# point_winner = 1 --> receiver wins the point
if point_winner == 1:
if self.receiver_current_score == 0:
self.receiver_current_score = self.receiver_current_score + 15
elif self.receiver_current_score == 15:
self.receiver_current_score = self.receiver_current_score + 15
elif self.receiver_current_score == 30:
self.receiver_current_score = self.receiver_current_score + 10
elif self.receiver_current_score == 40 and self.server_current_score != "A":
if self.receiver_current_score == self.server_current_score:
self.receiver_current_score = "A"
else:
self.receiver_current_score = "Win"
elif self.server_current_score == "A":
self.server_current_score=40
else:
self.receiver_current_score="Win"
else:
if self.server_current_score == 0:
self.server_current_score = self.server_current_score + 15
elif self.server_current_score == 15:
self.server_current_score = self.server_current_score + 15
elif self.server_current_score == 30:
self.server_current_score = self.server_current_score + 10
elif self.server_current_score == 40 and self.receiver_current_score != "A":
if self.server_current_score == self.receiver_current_score:
self.server_current_score = "A"
else:
self.server_current_score = "Win"
elif self.receiver_current_score == "A":
self.receiver_current_score=40
else:
self.server_current_score="Win"
return self.server_current_score,self.receiver_current_score