mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-16 19:05:05 +00:00
added encoding. Decided itertools.zip_longest was overkill, refactored to use simpler method.
This commit is contained in:
1 parent
1cf0963de5
commit
7333fc844e
3 files changed
+8
-5
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
class TennisGameDefactored1:
|
class TennisGameDefactored1:
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from tennis import TennisGame
|
from tennis import TennisGame
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from itertools import izip_longest
|
|
||||||
|
|
||||||
from tennis import TennisGame
|
from tennis import TennisGame
|
||||||
|
|
||||||
@@ -52,10 +53,10 @@ test_cases = [
|
|||||||
|
|
||||||
def play_game(p1Points, p2Points, p1Name, p2Name):
|
def play_game(p1Points, p2Points, p1Name, p2Name):
|
||||||
game = TennisGame(p1Name, p2Name)
|
game = TennisGame(p1Name, p2Name)
|
||||||
for p1, p2 in izip_longest(range(p1Points), range(p2Points)):
|
for i in range(max(p1Points, p2Points)):
|
||||||
if p1 is not None:
|
if i < p1Points:
|
||||||
game.won_point(p1Name)
|
game.won_point(p1Name)
|
||||||
if p2 is not None:
|
if i < p2Points:
|
||||||
game.won_point(p2Name)
|
game.won_point(p2Name)
|
||||||
return game
|
return game
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user