From fbb4ce847e2aeb3eafe59df5a2190cb9062d505c Mon Sep 17 00:00:00 2001 From: Hatice Yildirim <Hatice.Yildirim@student.reutlingen-university.de> Date: Sat, 22 Mar 2025 12:40:07 +0100 Subject: [PATCH] Mein Commit --- calculator.py | 13 +++++++++++++ counter.py | 35 +++++++++++++++++++++++++++++++++++ test.py | 5 +++++ 3 files changed, 53 insertions(+) create mode 100644 calculator.py create mode 100644 counter.py create mode 100644 test.py diff --git a/calculator.py b/calculator.py new file mode 100644 index 0000000..79532fc --- /dev/null +++ b/calculator.py @@ -0,0 +1,13 @@ +import unittest + +class Calculator: + def add(self, a, b): + return a + b + +class TestCalculator(unittest.TestCase): + def test_add(self): + c = Calculator() + self.assertEqual(c.add(2,3), 5) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/counter.py b/counter.py new file mode 100644 index 0000000..f6ee3bb --- /dev/null +++ b/counter.py @@ -0,0 +1,35 @@ +#Bei Einhabe des Strings "Decker" liefert die Funktion 3 +#Bei Eingabe eines leeren Strings soll 0 ausgegeben werden +#Bei Eingabe des Strings "Hallo" ohne E und D soll 0 ausgegeben werden + +from abc import ABC,abstractmethod +import unittest + +class ICounter (ABC): + @abstractmethod + def count_ED(self,s): + pass + +class Counter (ICounter): + #def count_ED(self,s): + #return s.count("e")+s.count("D") + pass + +class TestCounter (unittest.TestCase): + def test_count_ED_regular (self): + c=Counter() + res=c.count_ED ("Decker") + self.assertEqual(res,3) + def test_count_ED_empty (self): + c=Counter() + res=c.count_ED ("") + self.assertEqual(res,0) + def test_count_ED_wo (self): + '''Testet einen String ohne E und D''' + c=Counter() + res=c.count_ED ("Hallo") + self.assertEqual(res,0) + + +if __name__=="__main__": + unittest.main() diff --git a/test.py b/test.py new file mode 100644 index 0000000..d40dcf9 --- /dev/null +++ b/test.py @@ -0,0 +1,5 @@ +#Meine Übung, um es zu verstehen! +class Employee: + def __init__(self, name, age): + self.name = name + self.age = age \ No newline at end of file -- GitLab