From 0129c79bd74fb93ac2fb3daaa6f21837ae592922 Mon Sep 17 00:00:00 2001
From: linopino <lasse.pikkemaat@web.de>
Date: Wed, 26 Mar 2025 20:57:06 +0100
Subject: [PATCH] Umsetzung UML Digramm + Tests geschrieben

---
 src/__pycache__/interfaces.cpython-310.pyc    | Bin 530 -> 799 bytes
 .../stringcalculator.cpython-310.pyc          | Bin 0 -> 586 bytes
 src/interfaces.py                             |   5 ++++
 src/stringcalculator.py                       |   7 +++++
 .../test_romannumerals.cpython-310.pyc        | Bin 2458 -> 2458 bytes
 .../test_stringcalculator.cpython-310.pyc     | Bin 0 -> 1190 bytes
 tests/test_romannumerals.py                   |   3 ++-
 tests/test_stringcalculator.py                |  25 +++++++++++++++++-
 8 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100644 src/__pycache__/stringcalculator.cpython-310.pyc
 create mode 100644 tests/__pycache__/test_stringcalculator.cpython-310.pyc

diff --git a/src/__pycache__/interfaces.cpython-310.pyc b/src/__pycache__/interfaces.cpython-310.pyc
index 9c2c27ce8dbc3a9cbbc432aef7c2022428ab19de..d7953f25e6f8b9e6f58dfc3cdb55b061b176f472 100644
GIT binary patch
delta 430
zcmbQlGM|k%pO=@50SGQcJW2mHkyn<{WTLjRm^(uXOA2cXLkepuV>5FUOA1>sgC_gL
z5L3p_6T706KC=LIq%Z_CtYq|C$)L$}i={X<C#{GLC|U$Et%z$f8>1`Z=gB^d!G^pD
zQ8<eS#9{>!%s~7Zq>qDviBW<PEH<$~QlkiDgC^T8LC@flqRhN>=fs@k(wxMS{Gwaz
zd8N5YsYS&_>_8<GPfOMpaR3=boFD>Zxh7K)H;63;6M#4gWaTa9#FP}ULOvj`N)*Fz
zJ)pdwCVLS-NUs2h5Cjn*R~89_2q6$54k94_1hUc)<`;<q`C!+GfRuoEewwU6Ta%KD
om_Q<6gFyZU%OT7_7;%fkCO1E&G$+-L5vZ&f6f^=10!$*T0J}#|>i_@%

delta 202
zcmbQwHi?BdpO=@50SF!iJW21I$ScdJGErNZErlhRL6dc2iYa69#92{F#VkM-DGWd{
zM!%H|noPG?ic@paidcc7MeJZ=vKXT)WAWq|#^7R*aZph>ixb2G8Nv+2#cV)=gMo=r
uf)Om{r^#}QIWZ}@hzX<$qyj9A&5T<dHo5sJr8%i~j39$RCJHc!FaZE<^CB1k

diff --git a/src/__pycache__/stringcalculator.cpython-310.pyc b/src/__pycache__/stringcalculator.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..938708f3482e2cedde5ca28d3caf0cfceea2ad7f
GIT binary patch
literal 586
zcmZ9IOG^VW5P&nAwARuVh2lv>j|<YfA|g}}4;G=fT3FVdw5;x<CRtJGt^FZ-^e^RV
zFa8BjPF5*P2WFCa@XaG{x0{UQ=x#M#(fj3`st9r}NcABZWC#gMVFbXg7<$N;47r2_
zA9*N-%&&b@74yOFUJs3mvuQs}q9O@Rt|FJI%9?yYQOQPtj3^*EdQwaTauiE3s$q?|
zb-T04vs+n_-b<xzT}e}@Eb=OJ_pg)oN%cONIcR|}WQG|q-W=Yk%?B*J1;u<mP(U?5
zaO?}qb&*=0hBM3K%-EWqC9&~6E3`}|%1!;rRLhm0^iRh_Q(#=A<69NJ#CoRk2l;4j
za+E5&l+R<WqOmS75v?!Lo4r~dB07|ILkbYkg}3hJiajbC(C&>O$ih?xfo%psnq!f;
ze=7){iZJ=laO$GA38p&ExcMrk?OaaAsdkMUY!AxFz~{C@WA<oSsU~40wQ|=hlNCfs
TbR63_`<vn1-K>PQSl9antHg;y

literal 0
HcmV?d00001

diff --git a/src/interfaces.py b/src/interfaces.py
index bc8c8c3..7a3cc8e 100644
--- a/src/interfaces.py
+++ b/src/interfaces.py
@@ -3,4 +3,9 @@ from abc import ABC, abstractmethod
 class IRomanNumber(ABC):
     @abstractmethod
     def convert(self, n: int) -> str:
+        pass
+
+class IStringCalculator(ABC):
+    @abstractmethod
+    def add(self, numbers: str) -> int:
         pass
\ No newline at end of file
diff --git a/src/stringcalculator.py b/src/stringcalculator.py
index e69de29..41f666f 100644
--- a/src/stringcalculator.py
+++ b/src/stringcalculator.py
@@ -0,0 +1,7 @@
+from src.interfaces import IStringCalculator
+
+class StringCalculator(IStringCalculator):
+    def add(self, numbers: str) -> int:
+        if not numbers:
+            return 0
+        return sum(map(int, numbers.split(',')))
\ No newline at end of file
diff --git a/tests/__pycache__/test_romannumerals.cpython-310.pyc b/tests/__pycache__/test_romannumerals.cpython-310.pyc
index 2ef85d1aa0aaa5d708fc349e4ed24856b6f600f4..1809b2b966feaa1479662587eca1207db19195ad 100644
GIT binary patch
delta 22
ccmbOwJWH52pO=@50SN4ao}@=_<n84I06F{xh5!Hn

delta 22
ccmbOwJWH52pO=@50SLH)o}`;><n84I05@C(DgXcg

diff --git a/tests/__pycache__/test_stringcalculator.cpython-310.pyc b/tests/__pycache__/test_stringcalculator.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..31a224455e3a18f535acc76eafba13b427a27f89
GIT binary patch
literal 1190
zcmaiz&u<bz6vt=w2Ml!Suh80f@ZxE;A+1Ma3<(;eiNplGtR$0_nKsbf1!rc}lHS@s
z1mcOCf6rd^!nrpu`rc9z5pk0F&d>MW=gp6PrBWtPzP$Z*`q?JrD-ITm1A{tL{Q^V~
zK_e1iYeh7+0*hkbj_lY897>)M;RyGN2v?Gxduay+SrmmcOWl=Z#Kr`6(^g*n;uQRm
zrcbk-=PjeU$!Q~uI%yP|zJkf^<+%=SUn~|3>QMC|h$I0OB(MY())fhCVG9RZfDr{~
zT~QPa+JY#xh+odCucbDBMWEp5SHV6;Xh78-h#{Bcf^die9%$3I6r2{x%AGm&gl3MG
z(aD4;220=Tjfd@)Nkun}+pkpksjCO7-;-zNWnV~@Jdq#T1~7E4T<2%-+gojLp1E3@
zHv^2Wk;S9K+pEB9`L@n7z6&OZe|-RQK}Jw}bOc8<hC>?XHwUTM&5S5Co!Hq%sI^q)
z>H9Q{6q;vtD1<6NFHdPEC0y7;bPlUr#shPHgTDn!*NA#Rhxb;Zt~C26y4nC=h)9p8
z$fznPt9bV3jx{``Nb)3&-$}KL`*%Qw_t)e6VfA00p?iFE_~2-IXDw58&SXCJZ-DgP
zoXB5Kv|!Wpiy7lQ31i85R^~kJixhI?na4R^)@()LPgdI~Rg`@ce2NQ#m#6Sg<H>3?
zV1!X-GuyNCc?=YX-Gp<$6tFbu8q6Zt)T&eKCPu20up_m?OAe|yx%_Zv|AJw1jS!v_
m22-~{G6(%Gu;gg@YhsUP89l~J)|()#;8Bn6TCCzx=f_X{&>!;v

literal 0
HcmV?d00001

diff --git a/tests/test_romannumerals.py b/tests/test_romannumerals.py
index abc5266..35e2af3 100644
--- a/tests/test_romannumerals.py
+++ b/tests/test_romannumerals.py
@@ -97,4 +97,5 @@ class TestRomanNumber(unittest.TestCase):
 if __name__ == "__main__":
     unittest.main()
 
-#python -m unittest discover -s tests
\ No newline at end of file
+# python -m unittest tests.test_romannumerals
+# python -m unittest discover -s tests
\ No newline at end of file
diff --git a/tests/test_stringcalculator.py b/tests/test_stringcalculator.py
index b8e4935..f7c4c12 100644
--- a/tests/test_stringcalculator.py
+++ b/tests/test_stringcalculator.py
@@ -2,4 +2,27 @@
 # Bei Eingabe keiner Zahl soll eine 0 ausgegeben werden
 # Bei Eingabe einer 1 soll 1 ausgegeben werden
 # Bei Eingabe einer 3,4 soll 7 ausgegeben werden
-# Bei Eingabe einer 10,20 soll 30 ausgegeben werden
\ No newline at end of file
+# Bei Eingabe einer 10,20 soll 30 ausgegeben werden
+
+import unittest
+from src.interfaces import IStringCalculator
+from src.stringcalculator import StringCalculator
+
+class TestStringCalculator(unittest.TestCase):
+    def setUp(self):
+        self.calculator: IStringCalculator = StringCalculator()  # Zugriff über das Interface
+
+    def test_add_empty_string(self):
+        self.assertEqual(self.calculator.add(""), 0)
+
+    def test_add_single_number(self):
+        self.assertEqual(self.calculator.add("1"), 1)
+
+    def test_add_two_numbers(self):
+        self.assertEqual(self.calculator.add("10,20"), 30)
+
+if __name__ == "__main__":
+    unittest.main()
+
+# python -m unittest tests.test_stringcalculator
+# python -m unittest discover -s tests
\ No newline at end of file
-- 
GitLab