Beispiel #1
0
class Calculator(object):

    def __init__(self, input_string):
        self.input = Parser().parse(input_string)

    def add(self):
        if self.input == "":
            return ""
        else:
            return reduce(lambda x, y: x + y, map(lambda x: int(x), self.input.split(",")))
Beispiel #2
0
class Calculator(object):
    def __init__(self, input_string):
        self.input = Parser().parse(input_string)

    def add(self):
        if self.input == "":
            return ""
        else:
            return reduce(lambda x, y: x + y,
                          map(lambda x: int(x), self.input.split(",")))
Beispiel #3
0
 def __init__(self, input_string):
     self.input = Parser().parse(input_string)
Beispiel #4
0
 def test_that_it_converts_delimiters_to_commas(self):
     self.assertEquals(Parser().parse("//;\n1;2"), "1,2")
Beispiel #5
0
 def test_that_it_converts_newline_characters_to_commas(self):
     self.assertEquals(Parser().parse("1\n2,3"), "1,2,3")
Beispiel #6
0
 def __init__(self, input_string):
     self.input = Parser().parse(input_string)