From 4f6229dbb841162b35161f52a0604f612971bb82 Mon Sep 17 00:00:00 2001 From: Hatice Yildirim <Hatice.Yildirim@student.reutlingen-university.de> Date: Sun, 6 Apr 2025 04:14:25 +0200 Subject: [PATCH] inital commit --- .../__pycache__/Feature1.cpython-312.pyc | Bin .../stringCalculator.cpython-312.pyc | Bin .../stringCalculatorr.cpython-312.pyc | Bin .../BerishaAlma_2}/my_calculator.py | 0 .../BerishaAlma_2}/stringCalculatorr.py | 0 .../BerishaAlma_2}/your_calculator.py | 0 Other/GotsisWasili_2/TDD_StringCalculator.py | 110 ++++++++++++++++++ Other/GotsisWasili_2/my_calculator.py | 58 +++++++++ Other/GotsisWasili_2/stringCalculator.py | 88 ++++++++++++++ Other/GotsisWasili_2/your_calculator.py | 61 ++++++++++ .../stringCalculator.cpython-312.pyc | Bin 0 -> 6651 bytes Other/PikkemaatLasse_2/my_calculator.py | 58 +++++++++ .../__pycache__/interfaces.cpython-312.pyc | Bin 0 -> 660 bytes .../stringcalculator.cpython-312.pyc | Bin 0 -> 1920 bytes Other/PikkemaatLasse_2/stringCalculator.py | 88 ++++++++++++++ Other/PikkemaatLasse_2/your_calculator.py | 62 ++++++++++ .../stringCalculator.cpython-312.pyc | Bin 0 -> 8050 bytes Other/RafehDaniel_2/my_calculator.py | 58 +++++++++ Other/RafehDaniel_2/stringCalculatorr.py | 88 ++++++++++++++ Other/RafehDaniel_2/your_calculator.py | 86 ++++++++++++++ .../stringCalculator.cpython-312.pyc | Bin 0 -> 6653 bytes Other/WeishauptOrlando_2/my_calculator.py | 58 +++++++++ .../src/__pycache__/Count_ED.cpython-312.pyc | Bin 0 -> 843 bytes .../RomanConverter.cpython-312.pyc | Bin 0 -> 1878 bytes .../src/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 2369 bytes .../__pycache__/calculator.cpython-312.pyc | Bin 0 -> 2290 bytes .../__pycache__/interfaces.cpython-312.pyc | Bin 0 -> 2147 bytes .../string_calculator.cpython-312.pyc | Bin 0 -> 2410 bytes Other/WeishauptOrlando_2/stringCalculator.py | 88 ++++++++++++++ Other/WeishauptOrlando_2/your_calculator.py | 74 ++++++++++++ README.md | 93 --------------- 31 files changed, 977 insertions(+), 93 deletions(-) rename {BerishaAlma_2 => Other/BerishaAlma_2}/__pycache__/Feature1.cpython-312.pyc (100%) rename {BerishaAlma_2 => Other/BerishaAlma_2}/__pycache__/stringCalculator.cpython-312.pyc (100%) rename {BerishaAlma_2 => Other/BerishaAlma_2}/__pycache__/stringCalculatorr.cpython-312.pyc (100%) rename {BerishaAlma_2 => Other/BerishaAlma_2}/my_calculator.py (100%) rename {BerishaAlma_2 => Other/BerishaAlma_2}/stringCalculatorr.py (100%) rename {BerishaAlma_2 => Other/BerishaAlma_2}/your_calculator.py (100%) create mode 100644 Other/GotsisWasili_2/TDD_StringCalculator.py create mode 100644 Other/GotsisWasili_2/my_calculator.py create mode 100644 Other/GotsisWasili_2/stringCalculator.py create mode 100644 Other/GotsisWasili_2/your_calculator.py create mode 100644 Other/PikkemaatLasse_2/__pycache__/stringCalculator.cpython-312.pyc create mode 100644 Other/PikkemaatLasse_2/my_calculator.py create mode 100644 Other/PikkemaatLasse_2/src/__pycache__/interfaces.cpython-312.pyc create mode 100644 Other/PikkemaatLasse_2/src/__pycache__/stringcalculator.cpython-312.pyc create mode 100644 Other/PikkemaatLasse_2/stringCalculator.py create mode 100644 Other/PikkemaatLasse_2/your_calculator.py create mode 100644 Other/RafehDaniel_2/__pycache__/stringCalculator.cpython-312.pyc create mode 100644 Other/RafehDaniel_2/my_calculator.py create mode 100644 Other/RafehDaniel_2/stringCalculatorr.py create mode 100644 Other/RafehDaniel_2/your_calculator.py create mode 100644 Other/WeishauptOrlando_2/__pycache__/stringCalculator.cpython-312.pyc create mode 100644 Other/WeishauptOrlando_2/my_calculator.py create mode 100644 Other/WeishauptOrlando_2/src/__pycache__/Count_ED.cpython-312.pyc create mode 100644 Other/WeishauptOrlando_2/src/__pycache__/RomanConverter.cpython-312.pyc create mode 100644 Other/WeishauptOrlando_2/src/__pycache__/__init__.cpython-312.pyc create mode 100644 Other/WeishauptOrlando_2/src/__pycache__/calculator.cpython-312.pyc create mode 100644 Other/WeishauptOrlando_2/src/__pycache__/interfaces.cpython-312.pyc create mode 100644 Other/WeishauptOrlando_2/src/__pycache__/string_calculator.cpython-312.pyc create mode 100644 Other/WeishauptOrlando_2/stringCalculator.py create mode 100644 Other/WeishauptOrlando_2/your_calculator.py delete mode 100644 README.md diff --git a/BerishaAlma_2/__pycache__/Feature1.cpython-312.pyc b/Other/BerishaAlma_2/__pycache__/Feature1.cpython-312.pyc similarity index 100% rename from BerishaAlma_2/__pycache__/Feature1.cpython-312.pyc rename to Other/BerishaAlma_2/__pycache__/Feature1.cpython-312.pyc diff --git a/BerishaAlma_2/__pycache__/stringCalculator.cpython-312.pyc b/Other/BerishaAlma_2/__pycache__/stringCalculator.cpython-312.pyc similarity index 100% rename from BerishaAlma_2/__pycache__/stringCalculator.cpython-312.pyc rename to Other/BerishaAlma_2/__pycache__/stringCalculator.cpython-312.pyc diff --git a/BerishaAlma_2/__pycache__/stringCalculatorr.cpython-312.pyc b/Other/BerishaAlma_2/__pycache__/stringCalculatorr.cpython-312.pyc similarity index 100% rename from BerishaAlma_2/__pycache__/stringCalculatorr.cpython-312.pyc rename to Other/BerishaAlma_2/__pycache__/stringCalculatorr.cpython-312.pyc diff --git a/BerishaAlma_2/my_calculator.py b/Other/BerishaAlma_2/my_calculator.py similarity index 100% rename from BerishaAlma_2/my_calculator.py rename to Other/BerishaAlma_2/my_calculator.py diff --git a/BerishaAlma_2/stringCalculatorr.py b/Other/BerishaAlma_2/stringCalculatorr.py similarity index 100% rename from BerishaAlma_2/stringCalculatorr.py rename to Other/BerishaAlma_2/stringCalculatorr.py diff --git a/BerishaAlma_2/your_calculator.py b/Other/BerishaAlma_2/your_calculator.py similarity index 100% rename from BerishaAlma_2/your_calculator.py rename to Other/BerishaAlma_2/your_calculator.py diff --git a/Other/GotsisWasili_2/TDD_StringCalculator.py b/Other/GotsisWasili_2/TDD_StringCalculator.py new file mode 100644 index 0000000..ab815fa --- /dev/null +++ b/Other/GotsisWasili_2/TDD_StringCalculator.py @@ -0,0 +1,110 @@ +#Bei Eingabe des Strings "" liefert die Funktion 0 +#Bei Eingabe des Strings "1" liefert die Funktion 1 +#Bei Eingabe des Strings "1,2" liefert die Funktion 3 +#Bei Eingabe des Strings "1,2,3,4,5,6,7" liefert die Funkktion 28 +#Bei Eingabe des Strings "1\n2,3,4" liefert die Funkktion 10 +#Bei Eingabe des Strings "-5" liefert die Funkktion eine exception mit [“negatives not allowed†-5] +#Bei Eingabe des Strings "-5,-2,-2" liefert die Funkktion eine exception mit [“negatives not allowed†-5,-2,-2] +#Bei Eingabe des Strings "//;\n1;2" liefert die Funktion 3 wobei das Standard-Trennzeichen';' ist. +#Bei Eingabe des Strings "2,1001" liefert die Funktion 2 +#Bei Eingabe des Strings "2,10022\n6" liefert die Funktion 8 +#Bei Eingabe des Strings "//[***]\n1***2***3" mit dem Trennzeichen '***' liefert die Funktion 6 +#Bei Eingabe des Strings "//[*+*+*]\n1*+*+*2*+*+*3*+*+*220" mit dem Trennzeichen '***' liefert die Funktion 226 + +import unittest +from abc import ABC, abstractmethod + +#Interface für StringCalculator +class IStringCalculator(ABC): + @abstractmethod + def add(self, numbers:str) -> int: + pass + +#Implementierung der Calculator Klasse +class StringCalculator(IStringCalculator): + def add(self, numbers:str) -> int: + if numbers == "": + return 0 + + #Prüfen, ob ein benutzerdefiniertes Trennzeichen definiert wurde + + if numbers.startswith("//"): + delimiter_end_index = numbers.index("\n") #Zeilenumbruchs Position finden + delimiter = numbers[2:delimiter_end_index] # Trennzeichen, also alles zwischen "//" und "\n" extrahieren + + if delimiter.startswith("[") and delimiter.endswith("]"): + delimiter = delimiter[1:-1] # "[" und "]" entfernen + + numbers = numbers[delimiter_end_index + 1:] #Zahlen nach "\n" extrahieren + numbers = numbers.replace(delimiter,",") #Benutzerdefiniertes Trennzeichen durch "," ersetzen + + #Zeilenumbrüche ebenfals durch "," ersetzen + numbers = numbers.replace("\n",",") + + # String anhand von Kommas splitten, eine Liste der einzelnen Zahlen(in str) erzeugen und in Int umwandeln -> Ergebnis wäre z.B. bei add("1\n2,3,4") -> [1,2,3,4] + num_list = list(map(int, numbers.split(",",))) + + #Prüfung auf negative Zahlen + negatives = [n for n in num_list if n<0] + if negatives: + raise ValueError(f"negatives not allowed: {','.join(map(str, negatives))}") #Alle negativen Zahlen durch Kommas in getrennte Strings darstellen + + #Zahlen größer als 1000 aus Liste entfernen + num_list = [n for n in num_list if n <= 1000] + + return sum(num_list) #Summe berechnen (bei einer Zahln wird immernoch dieselbe Zahl ausgegeben) + + +#mplementierung der Testklasse für StringCalculator +class TestStringCalculator(unittest.TestCase): + def test_add_empty(self): + c = StringCalculator() + self.assertEqual(c.add(""), 0) + + def test_add_one_string(self): + c = StringCalculator() + self.assertEqual(c.add("1"), 1) + + def test_add_two_string(self): + c = StringCalculator() + self.assertEqual(c.add("1,2"), 3) + + def test_add_multiple_string(self): + c = StringCalculator() + self.assertEqual(c.add("1,2,3,4,5,6,7"), 28) + + def test_add_new_lines(self): + c = StringCalculator() + self.assertEqual(c.add("1\n2,3,4"), 10) + + def test_add_exception(self): + c = StringCalculator() + with self.assertRaises(ValueError) as context: + c.add("-5") + self.assertEqual(str(context.exception), "negatives not allowed: -5") + + def test_add_negative_numbers(self): + c = StringCalculator() + with self.assertRaises(ValueError) as context: + c.add("-5,-2,-2") + self.assertEqual(str(context.exception), "negatives not allowed: -5,-2,-2") + + def test_add_different_delimiters(self): + c = StringCalculator() + self.assertEqual(c.add("//;\n1;2"), 3) + + def test_add_numbers_greater_than_1000(self): + c = StringCalculator() + self.assertEqual(c.add("2,1001"),2) + self.assertEqual(c.add("2,10022\n6"),8) + + def test_delimiters_of_any_length(self): + c = StringCalculator() + self.assertEqual(c.add("//[***]\n1***2***3"), 6) + + def test_delimiters_of_any_length2(self): + c = StringCalculator() + self.assertEqual(c.add("//[*+*+*]\n1*+*+*2*+*+*3*+*+*220"), 226) + +if __name__ == "__main__": + unittest.main() diff --git a/Other/GotsisWasili_2/my_calculator.py b/Other/GotsisWasili_2/my_calculator.py new file mode 100644 index 0000000..ab49b59 --- /dev/null +++ b/Other/GotsisWasili_2/my_calculator.py @@ -0,0 +1,58 @@ +#Implementierung von PikkemaatLasse auf meinen Testfälle: StringCalculator +import unittest + +from TDD_StringCalculator import StringCalculator + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.calculator = StringCalculator() + + def test_implements_interface(self): + self.assertIsInstance(self.calculator, StringCalculator) + + def test_empty_string(self): + self.assertEqual(self.calculator.add(""), 0) + + def test_single_number(self): + self.assertEqual(self.calculator.add("1"), 1) + + def test_two_numbers(self): + self.assertEqual(self.calculator.add("1,2"), 3) + + def test_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3,4,5"), 15) + + def test_numbers_with_newline(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + + def test_numbers_with_multiple_newlines(self): + self.assertEqual(self.calculator.add("1\n2\n3\n4\n5"), 15) + + def test_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + self.assertEqual(str(context.exception), "Negatives not allowed: -2") + + def test_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,-3,4") + self.assertEqual(str(context.exception), "Negatives not allowed: -2, -3") + + def test_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + + def test_custom_delimiter_with_newline(self): + self.assertEqual(self.calculator.add("//;\n1;2\n3"), 6) + + def test_custom_delimiter_with_multiple_numbers(self): + self.assertEqual(self.calculator.add("//|\n1|2|3|4"), 10) + + def test_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + + def test_numbers_greater_than_1000_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n2;1001"), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/Other/GotsisWasili_2/stringCalculator.py b/Other/GotsisWasili_2/stringCalculator.py new file mode 100644 index 0000000..bd21dc8 --- /dev/null +++ b/Other/GotsisWasili_2/stringCalculator.py @@ -0,0 +1,88 @@ +from abc import ABC, abstractmethod +import unittest + +class IStringCalculator(ABC): + @abstractmethod + def add(self, numbers: str) -> int: + pass + +class StringCalculator(IStringCalculator): + def add(self, numbers: str) -> int: + if not numbers: + return 0 + + # Überprüfe, ob ein benutzerdefiniertes Trennzeichen angegeben ist + if numbers.startswith("//"): + delimiter_line_end = numbers.find("\n") + delimiter = numbers[2:delimiter_line_end] # Extrahiere das Trennzeichen + numbers = numbers[delimiter_line_end + 1:] # Entferne die erste Zeile mit dem Trennzeichen + else: + delimiter = ',' # Standard-Trennzeichen ist Komma + + # Ersetze alle Vorkommen des Trennzeichens und teile die Eingabe + numbers = numbers.replace("\n", delimiter) + nums = numbers.split(delimiter) + + # Filtere alle Zahlen, die größer als 1000 sind + nums = [int(num) for num in nums if int(num) <= 1000] + + # Prüfe auf negative Zahlen + negatives = [num for num in nums if num < 0] + + if negatives: + # Wenn negative Zahlen vorhanden sind, werfe eine Ausnahme + raise ValueError(f"Negatives not allowed: {', '.join(map(str, negatives))}") + + # Berechne die Summe der Zahlen, die <= 1000 sind + return sum(nums) + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.calculator = StringCalculator() + + def test_empty_string(self): + self.assertEqual(self.calculator.add(""), 0) + + def test_single_number(self): + self.assertEqual(self.calculator.add("1"), 1) + + def test_two_numbers(self): + self.assertEqual(self.calculator.add("1,2"), 3) + + def test_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3,4,5"), 15) + + def test_numbers_with_newline(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + + def test_numbers_with_multiple_newlines(self): + self.assertEqual(self.calculator.add("1\n2\n3\n4\n5"), 15) + + def test_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + self.assertEqual(str(context.exception), "Negatives not allowed: -2") + + def test_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,-3,4") + self.assertEqual(str(context.exception), "Negatives not allowed: -2, -3") + + def test_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + + def test_custom_delimiter_with_newline(self): + self.assertEqual(self.calculator.add("//;\n1;2\n3"), 6) + + def test_custom_delimiter_with_multiple_numbers(self): + self.assertEqual(self.calculator.add("//|\n1|2|3|4"), 10) + + def test_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + + def test_numbers_greater_than_1000_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n2;1001"), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/Other/GotsisWasili_2/your_calculator.py b/Other/GotsisWasili_2/your_calculator.py new file mode 100644 index 0000000..9742055 --- /dev/null +++ b/Other/GotsisWasili_2/your_calculator.py @@ -0,0 +1,61 @@ +import unittest +from stringCalculator import StringCalculator + +#mplementierung der Testklasse für StringCalculator +class TestStringCalculator(unittest.TestCase): + + def test_implements_interface(self): + c = StringCalculator() + self.assertIsInstance(self.c, StringCalculator) + + def test_add_empty(self): + c = StringCalculator() + self.assertEqual(c.add(""), 0) + + def test_add_one_string(self): + c = StringCalculator() + self.assertEqual(c.add("1"), 1) + + def test_add_two_string(self): + c = StringCalculator() + self.assertEqual(c.add("1,2"), 3) + + def test_add_multiple_string(self): + c = StringCalculator() + self.assertEqual(c.add("1,2,3,4,5,6,7"), 28) + + def test_add_new_lines(self): + c = StringCalculator() + self.assertEqual(c.add("1\n2,3,4"), 10) + + def test_add_exception(self): + c = StringCalculator() + with self.assertRaises(ValueError) as context: + c.add("-5") + self.assertEqual(str(context.exception), "negatives not allowed: -5") + + def test_add_negative_numbers(self): + c = StringCalculator() + with self.assertRaises(ValueError) as context: + c.add("-5,-2,-2") + self.assertEqual(str(context.exception), "negatives not allowed: -5,-2,-2") + + def test_add_different_delimiters(self): + c = StringCalculator() + self.assertEqual(c.add("//;\n1;2"), 3) + + def test_add_numbers_greater_than_1000(self): + c = StringCalculator() + self.assertEqual(c.add("2,1001"),2) + self.assertEqual(c.add("2,10022\n6"),8) + + def test_delimiters_of_any_length(self): + c = StringCalculator() + self.assertEqual(c.add("//[***]\n1***2***3"), 6) + + def test_delimiters_of_any_length2(self): + c = StringCalculator() + self.assertEqual(c.add("//[*+*+*]\n1*+*+*2*+*+*3*+*+*220"), 226) + +if __name__ == "__main__": + unittest.main() diff --git a/Other/PikkemaatLasse_2/__pycache__/stringCalculator.cpython-312.pyc b/Other/PikkemaatLasse_2/__pycache__/stringCalculator.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f8f6330f0744cb9f2196855a68b226d8671fd74e GIT binary patch literal 6651 zcmd^DT}&I<6~6OlkBuGkmn<gyI7xRCC+5dCkZd47gshTO3HgC!6PMjt$1@=gwxKh_ z5?e-1t5hXws_a&6L)EQHpBh9}(Wmm7)jm|}i>X7Q(@Nc{eOR8#0@7-E>NzvEgN;qP zFUvzO;`5y|=ia&J=bm%!{gd5pCD3j;J|Fy#jgWugL$-05&e{}oo)VFWRD?vS02QSJ zG=<M}gb6S-IY&h1ArV=LnqiDF0amASKs8Bhj>_p&Gf;Vnxd-1XY&lM|#EX`pLxjkc zGy&eqLQX<vG9-$`={W7SF5|PC)|l=yJ=(6|ZAF!XAvG$gcZbE^(B|<u!QKGsQzDT7 zC6WLwF(M_gA}w)uSP+QKejs3qvu;kSxX`D{;n-kLFcKP#1l3_#Gsi}ww<TH8OtPeo z%CQi=`7_W*b*!=aSK?%v>Yc^~vWgVBBb$M$AivAC@qXy|z;y*C8aN+R!y!qy6^@8u zIUF50D=9<j@W?=`Pv}2;R_Iog@L((|#Z*OT^$qm*Zzf4d^bcHC?@IE(mGIDz6b%N| zi$O(^1m6ItBX9A|BXNxhieh5-7P*>%j5<;f9*|FY+ZuF8uiLEgf)EQvB|*@vf)E`R zM<dv`3BtEWgAwD6jPhy>d{1M-F;(6Lk8&A;1Hq19$^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&5`*r^+lrTTB9xd%-+YUrW z*fztylXiB_K?QbdNA*<J(vq}#lfI-s*|v;lui}1lWE)Mr+-k-JWa9K!RaxN-mtY;+ zR<G}-on3Rc7x?ZS)t$-b@wT>lWoJpX838O?fDOu05U*X-yTO<MBU=;O1hA5WuHe^B zBVftAQ?bU1`^(q)3i;b~w<#%#vC|5-QQ|^r|M`kj^`V-sW_8u;t|+{V!Be8_N9aI! z6QK*?6awZ7`2xa4gkA(){r%Xxfp8N6lf7;Y<8JIQJ|Y~1e+5T9B&%?1+_Y+<xORjN zgkuP&5IPZhs8tig^-`-=hPwtxaVL;`8psrPM#s)IonU+lKY&-@(O@_x2yj`*1aF6A z{V0i*qsEWM!Yb<DxZuXCB8^AQ_5|VPL0@Az(pa3JK!gpx%eYTJDZdLmSPv?w%N2&A zsDF?He<O}{mZ9vE%sPReb!#2vOucq!oxtyUR}*!bnmo3+*E7G@vrh17<voh9wu!`_ Z8RrsP@!<RqE`9gX_b;z7gss(u`7aFufgAt; literal 0 HcmV?d00001 diff --git a/Other/PikkemaatLasse_2/my_calculator.py b/Other/PikkemaatLasse_2/my_calculator.py new file mode 100644 index 0000000..1397276 --- /dev/null +++ b/Other/PikkemaatLasse_2/my_calculator.py @@ -0,0 +1,58 @@ +#Implementierung von PikkemaatLasse auf meinen Testfälle: StringCalculator +import unittest + +from src.stringcalculator import StringCalculator + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.calculator = StringCalculator() + + def test_implements_interface(self): + self.assertIsInstance(self.calculator, StringCalculator) + + def test_empty_string(self): + self.assertEqual(self.calculator.add(""), 0) + + def test_single_number(self): + self.assertEqual(self.calculator.add("1"), 1) + + def test_two_numbers(self): + self.assertEqual(self.calculator.add("1,2"), 3) + + def test_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3,4,5"), 15) + + def test_numbers_with_newline(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + + def test_numbers_with_multiple_newlines(self): + self.assertEqual(self.calculator.add("1\n2\n3\n4\n5"), 15) + + def test_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + self.assertEqual(str(context.exception), "Negatives not allowed: -2") + + def test_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,-3,4") + self.assertEqual(str(context.exception), "Negatives not allowed: -2, -3") + + def test_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + + def test_custom_delimiter_with_newline(self): + self.assertEqual(self.calculator.add("//;\n1;2\n3"), 6) + + def test_custom_delimiter_with_multiple_numbers(self): + self.assertEqual(self.calculator.add("//|\n1|2|3|4"), 10) + + def test_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + + def test_numbers_greater_than_1000_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n2;1001"), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/Other/PikkemaatLasse_2/src/__pycache__/interfaces.cpython-312.pyc b/Other/PikkemaatLasse_2/src/__pycache__/interfaces.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ac53ca6f524d1c5c8f88faf49192e432080c7686 GIT binary patch literal 660 zcmZWm&ubGw6n?X_n}nJzi0!>72<xGg<R&822DDJ3V0v&_7$!TDbjj|fotZtvlZV{= z1Ja|{(to7jKOl2a@Z>Evdg;kG-Bv0N%=f<c_Wk(g?dLFD13VY^mgA3TzdPsl1UF>$ z1jzyf2$DlVVp4dqN5F%ZAiOyUD#<ymb7MO5qu_^gBG1y@7khS{54BM|HH9=sQ<2t* zHU6FO82trEh>3vMlT;At3r_|kU(mUKep3@STz7ka|E*D3Io{)WTIJkKm2H+)F_cQ% zhLWaIW$N7>gWTy``3MV`K}7mzPM@!3K2lALYL~yYb!F10$)UzZ$t!NMRI+zjE;5xB zNl)sDnI0!Q9X9Co*sj*uxGZF8G~4MUgTdX9bir=&+8jxhyvZgLS#WL+xYm+&60OoC zD~(hmo=UxaJhPMw@qY8aS8Ze1N!D&nAK+W7y+Q*0sA*e_mAsIQ*)_(Bsi<<t+l-x5 zJg>hfS86Hl-clT=LUfh;*=pTE+d<<N+<NpwggJZ(9xOc)gs0slp!w9jbY?}NvGLQz z>vC7wk9?FqOqHv?9#=Q~cgR)iSuOCn+QdA9S8pIJDIw%5Jo@ER5}wlEfabdQA8os! AssI20 literal 0 HcmV?d00001 diff --git a/Other/PikkemaatLasse_2/src/__pycache__/stringcalculator.cpython-312.pyc b/Other/PikkemaatLasse_2/src/__pycache__/stringcalculator.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d7070b361211a079a6b1902fa1be15345de2abe3 GIT binary patch literal 1920 zcmZ`)O-vg{6rR~#{~HW;0yJPS1T{G2Cjq6T`BNi1B_xsilcX)Kqt(VUm@Vryomq!K z*HRVbz#&q@i6~JeDj}69ha&Y7sXbKT5~-I(juK~^N=WUY+)zlR7FB9zv6omhox_{= z-hA`DH*e?7{!~-r1#CR@t!IWD0Q_nh_F(qb*yv@`96$g;1!Q3oLQCfqF3E9V2q6AC zKmvyM_%b}nPjOMlnq@?xSwDPUBeI%_NlH4eNLr30(q&v(3Ke6cg(-6YgCs;C$sve& z#9?7nVDv)LF(pJDX5CII)1~IKmocHHlVB}R)HGMc?Pj`_)5hD(I|p<~;S|*2r?3iB zQ4x2q;w3WTb$A65pH?{!V5hTJuUY%;x>V61-bNHS9U_O$?EwW|=U*AiX=6zvL%6DF z>}*`y2&c{?H}WtxLFIJ5Am~u%kb9aT5nx^`AJ2aobOCwqRci5n7{pg&JV5i=JX+1R zR%>f4PQ9(aoEbx<Zgw==E;w{Y9DM0aa~Y84F0oryaOzG3$5~bs-tg$oS?-2k00kHG zyGU(Swf(y54)|*Oi?Eu%im7IN&kiO>!KsDp+;oSX$$79BXxsOq6A(WHRndGl?i!o~ zSNRbz3DX>8ITxIhOxjwsHbE?sX|Att6MFNnGyS5PS^h!M<P4^fcXA{vX-6UnIX$LD zuH+PjYRd~Mk~3@8woUlSCcLy}6>IGuHa1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ator.py new file mode 100644 index 0000000..bd21dc8 --- /dev/null +++ b/Other/PikkemaatLasse_2/stringCalculator.py @@ -0,0 +1,88 @@ +from abc import ABC, abstractmethod +import unittest + +class IStringCalculator(ABC): + @abstractmethod + def add(self, numbers: str) -> int: + pass + +class StringCalculator(IStringCalculator): + def add(self, numbers: str) -> int: + if not numbers: + return 0 + + # Überprüfe, ob ein benutzerdefiniertes Trennzeichen angegeben ist + if numbers.startswith("//"): + delimiter_line_end = numbers.find("\n") + delimiter = numbers[2:delimiter_line_end] # Extrahiere das Trennzeichen + numbers = numbers[delimiter_line_end + 1:] # Entferne die erste Zeile mit dem Trennzeichen + else: + delimiter = ',' # Standard-Trennzeichen ist Komma + + # Ersetze alle Vorkommen des Trennzeichens und teile die Eingabe + numbers = numbers.replace("\n", delimiter) + nums = numbers.split(delimiter) + + # Filtere alle Zahlen, die größer als 1000 sind + nums = [int(num) for num in nums if int(num) <= 1000] + + # Prüfe auf negative Zahlen + negatives = [num for num in nums if num < 0] + + if negatives: + # Wenn negative Zahlen vorhanden sind, werfe eine Ausnahme + raise ValueError(f"Negatives not allowed: {', '.join(map(str, negatives))}") + + # Berechne die Summe der Zahlen, die <= 1000 sind + return sum(nums) + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.calculator = StringCalculator() + + def test_empty_string(self): + self.assertEqual(self.calculator.add(""), 0) + + def test_single_number(self): + self.assertEqual(self.calculator.add("1"), 1) + + def test_two_numbers(self): + self.assertEqual(self.calculator.add("1,2"), 3) + + def test_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3,4,5"), 15) + + def test_numbers_with_newline(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + + def test_numbers_with_multiple_newlines(self): + self.assertEqual(self.calculator.add("1\n2\n3\n4\n5"), 15) + + def test_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + self.assertEqual(str(context.exception), "Negatives not allowed: -2") + + def test_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,-3,4") + self.assertEqual(str(context.exception), "Negatives not allowed: -2, -3") + + def test_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + + def test_custom_delimiter_with_newline(self): + self.assertEqual(self.calculator.add("//;\n1;2\n3"), 6) + + def test_custom_delimiter_with_multiple_numbers(self): + self.assertEqual(self.calculator.add("//|\n1|2|3|4"), 10) + + def test_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + + def test_numbers_greater_than_1000_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n2;1001"), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/Other/PikkemaatLasse_2/your_calculator.py b/Other/PikkemaatLasse_2/your_calculator.py new file mode 100644 index 0000000..ff558d7 --- /dev/null +++ b/Other/PikkemaatLasse_2/your_calculator.py @@ -0,0 +1,62 @@ +#Meine Implementierungen auf Testfälle anderer Studierenden testen: StringCalculator + +import unittest +from stringCalculator import StringCalculator +from stringCalculator import IStringCalculator + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.calculator: IStringCalculator = StringCalculator() # Zugriff über das Interface + + def test_implements_interface(self): + self.assertIsInstance(self.calculator, IStringCalculator) + + 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) + + def test_add_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3"), 6) + self.assertEqual(self.calculator.add("10,20,30,40"), 100) + + def test_add_with_newline_separator(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + self.assertEqual(self.calculator.add("10\n20\n30"), 60) + + def test_add_single_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + print(str(context.exception)) + self.assertEqual(str(context.exception), "Negative nicht erlaubt: [-2]") + + def test_add_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("-10\n-20,-30") + print(str(context.exception)) + self.assertEqual(str(context.exception), "Negative nicht erlaubt: [-10, -20, -30]") + + def test_add_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + self.assertEqual(self.calculator.add("//x\n7x8\n9"), 24) + + def test_invalid_custom_delimiter_format(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("//;1;2") + print(str(context.exception)) + + def test_ignore_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + self.assertEqual(self.calculator.add("1002,50200"), 0) + + def test_add_with_custom_delimiter_multiple_characters(self): + self.assertEqual(self.calculator.add("//[**]\n1**2**3"), 6) + self.assertEqual(self.calculator.add("//[###]\n10###20###30"), 60) + +if __name__ == "__main__": + unittest.main() + diff --git a/Other/RafehDaniel_2/__pycache__/stringCalculator.cpython-312.pyc b/Other/RafehDaniel_2/__pycache__/stringCalculator.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7de4da4cc32c14a02dae09283960657292444219 GIT binary patch literal 8050 zcmd5>No*U}8Gf^HINT{xt1a1-rNpK~EtFzsagrjIyu`KTAa)ija)}Y&NTN)U>deTF z22|k|ZYw)(W4A!9wm>2DP}pz}JqBnG0h&XBUZl{0m_dLF=%u=;mJWr`BK`lz#iB$i zITW=9;5Rex{cro;zs=)cJsu~4>nqpl=xdFH{2gD4m#y%yHV+T?2qlzDl0m%lNp6B4 z<R^qdfg?OQMW}FtP*LR{3i&pJA}h5)sicafQX4C^L#eEiad)BrO}CPyU6rZh${|9u z08c<Rut})!_^@#2$TT<2g`F$-J`m<D;q~KvmRA|p4NZv~6RI(mrtyL>yOkF9EWF-> z?gu$a26<JWoGMaYwT+0dAh9^WpfoLpZC1@27Yr?t8tqe(@u{R@q&3T)nwl6^HQkal z)tJ&!aenhK@Qie<iENZ<@_-w7Kwy5Nt|mt`JCy1u9|~>g@t23*)}f=J(~6OZtFcRo zBu!|EiJ^W~zha~(hq`-W7yJ8Tuj_hZ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9m=mVZT literal 0 HcmV?d00001 diff --git a/Other/RafehDaniel_2/my_calculator.py b/Other/RafehDaniel_2/my_calculator.py new file mode 100644 index 0000000..29b3e3c --- /dev/null +++ b/Other/RafehDaniel_2/my_calculator.py @@ -0,0 +1,58 @@ +#Umsetzungen von RafehDaniel auf meinen Testfälle: StringCalculator +import unittest + +from stringCalculator import StringCalculator + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.calculator = StringCalculator() + + def test_implements_interface(self): + self.assertIsInstance(self.calculator, StringCalculator) + + def test_empty_string(self): + self.assertEqual(self.calculator.add(""), 0) + + def test_single_number(self): + self.assertEqual(self.calculator.add("1"), 1) + + def test_two_numbers(self): + self.assertEqual(self.calculator.add("1,2"), 3) + + def test_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3,4,5"), 15) + + def test_numbers_with_newline(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + + def test_numbers_with_multiple_newlines(self): + self.assertEqual(self.calculator.add("1\n2\n3\n4\n5"), 15) + + def test_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + self.assertEqual(str(context.exception), "Negatives not allowed: -2") + + def test_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,-3,4") + self.assertEqual(str(context.exception), "Negatives not allowed: -2, -3") + + def test_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + + def test_custom_delimiter_with_newline(self): + self.assertEqual(self.calculator.add("//;\n1;2\n3"), 6) + + def test_custom_delimiter_with_multiple_numbers(self): + self.assertEqual(self.calculator.add("//|\n1|2|3|4"), 10) + + def test_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + + def test_numbers_greater_than_1000_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n2;1001"), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/Other/RafehDaniel_2/stringCalculatorr.py b/Other/RafehDaniel_2/stringCalculatorr.py new file mode 100644 index 0000000..bd21dc8 --- /dev/null +++ b/Other/RafehDaniel_2/stringCalculatorr.py @@ -0,0 +1,88 @@ +from abc import ABC, abstractmethod +import unittest + +class IStringCalculator(ABC): + @abstractmethod + def add(self, numbers: str) -> int: + pass + +class StringCalculator(IStringCalculator): + def add(self, numbers: str) -> int: + if not numbers: + return 0 + + # Überprüfe, ob ein benutzerdefiniertes Trennzeichen angegeben ist + if numbers.startswith("//"): + delimiter_line_end = numbers.find("\n") + delimiter = numbers[2:delimiter_line_end] # Extrahiere das Trennzeichen + numbers = numbers[delimiter_line_end + 1:] # Entferne die erste Zeile mit dem Trennzeichen + else: + delimiter = ',' # Standard-Trennzeichen ist Komma + + # Ersetze alle Vorkommen des Trennzeichens und teile die Eingabe + numbers = numbers.replace("\n", delimiter) + nums = numbers.split(delimiter) + + # Filtere alle Zahlen, die größer als 1000 sind + nums = [int(num) for num in nums if int(num) <= 1000] + + # Prüfe auf negative Zahlen + negatives = [num for num in nums if num < 0] + + if negatives: + # Wenn negative Zahlen vorhanden sind, werfe eine Ausnahme + raise ValueError(f"Negatives not allowed: {', '.join(map(str, negatives))}") + + # Berechne die Summe der Zahlen, die <= 1000 sind + return sum(nums) + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.calculator = StringCalculator() + + def test_empty_string(self): + self.assertEqual(self.calculator.add(""), 0) + + def test_single_number(self): + self.assertEqual(self.calculator.add("1"), 1) + + def test_two_numbers(self): + self.assertEqual(self.calculator.add("1,2"), 3) + + def test_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3,4,5"), 15) + + def test_numbers_with_newline(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + + def test_numbers_with_multiple_newlines(self): + self.assertEqual(self.calculator.add("1\n2\n3\n4\n5"), 15) + + def test_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + self.assertEqual(str(context.exception), "Negatives not allowed: -2") + + def test_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,-3,4") + self.assertEqual(str(context.exception), "Negatives not allowed: -2, -3") + + def test_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + + def test_custom_delimiter_with_newline(self): + self.assertEqual(self.calculator.add("//;\n1;2\n3"), 6) + + def test_custom_delimiter_with_multiple_numbers(self): + self.assertEqual(self.calculator.add("//|\n1|2|3|4"), 10) + + def test_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + + def test_numbers_greater_than_1000_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n2;1001"), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/Other/RafehDaniel_2/your_calculator.py b/Other/RafehDaniel_2/your_calculator.py new file mode 100644 index 0000000..64929f3 --- /dev/null +++ b/Other/RafehDaniel_2/your_calculator.py @@ -0,0 +1,86 @@ +#Meine Implementierungen auf Testfälle anderer Studierenden testen: StringCalculator + +import unittest +from stringCalculator import StringCalculator + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.c = StringCalculator() + + def test_implements_interface(self): + self.assertIsInstance(self.c, StringCalculator) + + def test_empty(self): + res = self.c.add("") + self.assertEqual(res, 0) + + def test_oneNumber(self): + res = self.c.add("1") + self.assertEqual(res, 1) + + def test_addingTwoNumbers(self): + res = self.c.add("1,2") + self.assertEqual(res, 3) + + def test_addingTwoNumbersWithZero(self): + res = self.c.add("0,5") + self.assertEqual(res, 5) + + def test_handleFloat(self): + res = self.c.add("3.5") + self.assertEqual(res, "only integers allowed") + + def test_handleLetter(self): + res = self.c.add("1, z") + self.assertEqual(res, "only integers allowed") + + def test_addWithBackslashN(self): + res = self.c.add("1\n2,3") + self.assertEqual(res, 6) + + def test_negativeValues(self): + res = self.c.add("-3") + self.assertEqual(res, "negatives not allowed") + + def test_delimiter(self): + res = self.c.add("//;\n1;2") + self.assertEqual(res, 3) + + def test_thousandone(self): + res = self.c.add("2, 1001") + self.assertEqual(res, 2) + + def test_multidelimiter(self): + res = self.c.add("//[***]\n1***2***3") + self.assertEqual(res, 6) + + def test_multi_negative(self): + res = self.c.add("-3, -4") + self.assertEqual(res, "negatives not allowed " + str([-3, -4])) + + def test_space_between_numbers(self): + res = self.c.add(" 4 , 5") + self.assertEqual(res, 9) + + def test_multiple_num_with_thousandone(self): + res = self.c.add(" 2, 1001, 5") + self.assertEqual(res, 7) + + def test_empty_text(self): + res = self.c.add("//;\n") + self.assertEqual(res, 0) + + def test_one_number_with_empty_string(self): + res = self.c.add("1,") + self.assertEqual(res, 1) + + def test_negative_with_positive(self): + res = self.c.add("-2, 5") + self.assertEqual(res, "negatives not allowed") + + def test_mixture(self): + res = self.c.add("//;\n-1;2;1001;-3") + self.assertEqual(res, "negatives not allowed " + str([-1, -3])) + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/Other/WeishauptOrlando_2/__pycache__/stringCalculator.cpython-312.pyc b/Other/WeishauptOrlando_2/__pycache__/stringCalculator.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2075e23bed85e561a84eea481d9e4a3faf3ec4a0 GIT binary patch literal 6653 zcmd^DTTC0-89sBf$HtDiC5s6cC+TkD#9V9x$p&&EWR;}akWC;rm)%*%GfSNKLT82& zTSiT*tV+~W*{#}!s#}#lHHfOBPvteMeW=tIQ-?yQmAX~?usoFoq}B4&|DUlPY;4kf zSsr>2pU?dBpEKvbod5sN`IFslCD3j<J|F&%jgWugL#}bz&e{}oo)D3URD?vS02QSJ zG=<M}gb6S-IY&h10TEe=nqiDF0amASKs8Bhp33P|Gf;VnxdY!TZh20##EX`@hX|3Y zX#%{}#hir9WJwfB&<WaYUB+iOtuei4`m|laTZ$?NLuyn~Z^y;{(B|=Z!CnLE6C#lS zC6WLwF(M_gA}w+6u^<qe`#`{yVBMTnbzwl2!?EGMU?eme394~fGsi}ww<KB7OtPeo z%CQi=`7_W*b*!=aR}y5J>Yv61vWgUWPc{QpL4KEO<6h|a&{YK{8af|T!y!qy8IFiy zIUF52D=Bx?_{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K8xl*hbF<@;L28bO}dRYZAs&-l+T6!^42ap=nQ_OoZVZB z?OyTR=0Ur+l(YL=3;boYdkfmVWkdcZOkZH^udldFn%mmCt=?{*d<+&*x}Gp{X=qeY z<53}h=-V!r7W3*x+AebhGR|XjP*?VBjfY>OE-YDHSpD+Jvf9|M`&Y4qg^BfOc^}($ zAUeXf8TRdrvwIFIuv0s#r;4_=l+~N^rTnRmWjuS8_M0QyXzImQGp-<$r@yMoif6b8 z>)5t>eJA7WnY*>X_wK0fOg@jdz1=H2%c{)?V7UTpSeAl#?V{ce#snDIp4=vYl^ygJ ze(f{@mdra9Ypl4xeBCdRze9JMvZ5F}t#}(HFO>J6uQ=5Js_Al0SN-m);=33;CCYw; zE`-++dJs+_V6KoaAiRmtkD#l65PR1UZXjT?*R5gPjUC2EgoE&};HU>=6>g1NR!tPw ziO_{`4B-?)H$oq^YGSy4YSqecR{$yQ1d>k!nc~jq*uAC`j8EYQ@CrN{495fkE(@99 zt&prAC9!hU_|aHcMg1EW+;~-_@u=CpAly9YYpg^XixU)yu)+5j_vt6)cYp`$K?QZW z!cY|T4|3pd#IepYlzoy}C-AdwZJ?a#R}QTc_+9U5p-xki#}@Z`=J$Hm2|lg7OA*#K ck^D2`Tw<&4pZ~$d?_GTV(h5V^dR>_R0+t7Y7ytkO literal 0 HcmV?d00001 diff --git a/Other/WeishauptOrlando_2/my_calculator.py b/Other/WeishauptOrlando_2/my_calculator.py new file mode 100644 index 0000000..6dd72eb --- /dev/null +++ b/Other/WeishauptOrlando_2/my_calculator.py @@ -0,0 +1,58 @@ +#Implementierung von WeishauptOrlando auf meinen Testfälle: StringCalculator +import unittest + +from src.string_calculator import StringCalculator + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.calculator = StringCalculator() + + def test_implements_interface(self): + self.assertIsInstance(self.calculator, StringCalculator) + + def test_empty_string(self): + self.assertEqual(self.calculator.add(""), 0) + + def test_single_number(self): + self.assertEqual(self.calculator.add("1"), 1) + + def test_two_numbers(self): + self.assertEqual(self.calculator.add("1,2"), 3) + + def test_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3,4,5"), 15) + + def test_numbers_with_newline(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + + def test_numbers_with_multiple_newlines(self): + self.assertEqual(self.calculator.add("1\n2\n3\n4\n5"), 15) + + def test_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + self.assertEqual(str(context.exception), "Negatives not allowed: -2") + + def test_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,-3,4") + self.assertEqual(str(context.exception), "Negatives not allowed: -2, -3") + + def test_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + + def test_custom_delimiter_with_newline(self): + self.assertEqual(self.calculator.add("//;\n1;2\n3"), 6) + + def test_custom_delimiter_with_multiple_numbers(self): + self.assertEqual(self.calculator.add("//|\n1|2|3|4"), 10) + + def test_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + + def test_numbers_greater_than_1000_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n2;1001"), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/Other/WeishauptOrlando_2/src/__pycache__/Count_ED.cpython-312.pyc b/Other/WeishauptOrlando_2/src/__pycache__/Count_ED.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a69a4d220c6fc349a593a3e05153d521821d4c19 GIT binary patch literal 843 zcmZ`%y=xRf6rb7MJCBgBLdC*jAmC*aJS27^Ld=DjCJ_=5kA-2~d3QUyH+Rm=8WJK{ zq)12+yF@HZVI%o7EN!%t0YR{`JGj`Sa^`L$LGTst`~BW~Gw<`**a))J9PPEr7@?oe zIHyvf^lw<@5HZAXhT6D+G4jw7V%`p7KHw97nAh+&gRu0=86h^6<%LczG{|Ha9rB<s z`q!;;hyXP(Lk*8%@R<ieGhqHs&?q?|bEyC@Sedc}olB8;7r-2rYu!%=SljrSUEp6j zDIBk`jTeJn%whPXsQORbJCASKvNaU?`9rHTK7B|tO&A9<FSg<|BMc<DpC_r(@lz0_ zx>zN-V5C~F5-tdE0d2CTB^NC+y$~z7xhxb2#WjBkVa?#W!Hc11N_n>n(v%YSc-9US zWKCJNEtT7ykTad!i5@ACDtZuWo&bHqGsY!vM|Duob*CHMnxpIWI-OUFw?rF+R`k|f zw7!1P1<rXpTGc7Y=rM4W#(7t-$}ASFL+2tTlW6e%bg^FRZkozqAPQ`2viO$TxyPM} znzrmU`Y}3ou(Y?dzr2gTO-vqa>}|YJ``btH`_|jmaq=$vIx+L5GSj!YXeBJ03Z)`$ z1Epq!(sqaCnbSupeUZmm5%HCl#^*xI30w6M$w@2ZxMQyIfVoRhS1j8>J<l)A9!>R- z6~|MjP7Ett@=EBNal2W~!hvkY2`K4qVu*CrX@AkrDtCty-ILdBz#WOYY+2987=K4o Pr{w_8?xw$y6@#ij2FuRQ literal 0 HcmV?d00001 diff --git a/Other/WeishauptOrlando_2/src/__pycache__/RomanConverter.cpython-312.pyc b/Other/WeishauptOrlando_2/src/__pycache__/RomanConverter.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a767b8ed10891178c55225d35773572f541d007e GIT binary patch literal 1878 zcmZWpO>7%Q6rS0?*v=-YQ`@wKwk{M>7ZkNADixHXDy|^VQkAAnVi~O#@5I^GUZ=C` zO0jGyLOD342S-Axs}>P)0_Bc+;8uwXmy{f^Mnyv6f^Q}Xm!5cUH*Ou6!}n(1yuX=w z-~2K#5Fs#T^-lgRm5@Ji(H*e%$JS{O_lQL-S|CN5p_Et>lPsCZvx=oGDH%l~9}-Jl zB9_MJnjE-g)P=rOsEvyh6+;uBm5Qb_UUF_T?lCT8r(6^oXI_~*IU2b5h-opz)*XO* zBoAr7qcsXr0tsnrvZd6NDzTKCX+ro(@40uCRB2V&4}KMikhL9sntVP?NKLKERcU8; z0M>Gk^-HiOcVh~vDwbNo-52rc-IG=MDoJVOw;}K+!2xVIM3UJKOQu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VA4=q`wuOD+=)WKPK@k{*L99x+NUW^gbc$mi_9=Y#4w5_t6adjZWy=9 zW?^SXc0IUNI4^$(ynZ0Qvwt1@I4FF;CwB1>mq<s7tMO*8LqM$NwowEgXpA`r;cFR% zaE#BIIp%UC3O|eR9s+(UL166B7s;N5&ISdZ;~&5V{=F{Rc4SKF@8oz#i_>@m^HNB^ Qg<|_e0#wF71cV>xUt@9O%m4rY literal 0 HcmV?d00001 diff --git a/Other/WeishauptOrlando_2/src/__pycache__/__init__.cpython-312.pyc b/Other/WeishauptOrlando_2/src/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e6c31dbb7a9c3a386da2249f266946ebeb300bc4 GIT binary patch literal 2369 zcmbtVO>EO<82-NaCyC>RG^M3kX)$A{P1=yZrZ9dg(WZr#QnamO5Q3}_f3z-6(%H@m zKJ|n;!J*n^mC&SWr%hanCXF3-K-%E2T>?qf)e;)rPTWGdOmNv}yG~2RxXe=h{y)$A zz26)6_l5=r;O8n^n>@(^@V8;uk9$*jIYt2RH4uORC6I?{2o2pKIr2oBFm*yA^HiG3 z(`nkYNy(XarCkspw?JL%0zi&B0D^Zn0n^MR5a@4V+JihPaG3)j&AI{3Xb_x;y#oXn zVy4^eHnt>U??TJE1HK_`9fI5MlUB87%U5TPU|gck+=!W3%<M;g%)AdXH*NAZnY@kD z!7V;pLrpgB4&MFm;Jt})sXA}7$<kosK(k-eJRP<<wxr;-vuyd!>|J)2E#H~#v$Jez zWebgO+PGU<@Y_CHTDfMdK9RS?cH2H%ZgRZsc8tAn)u*%v-%c~WomSMkxfg-@UIfhh z*)yHonv|`ffX%eye%`VdH<$we?fL-7fwa%O6Kmt#$oFRLMIbO~-zDDyy#0}-&B9r5 zowx{Q;U+?B9l_}BKM`)Do%O+%=SJ&6s566EDOZxRYEj0PbFf${s7MYvbnnN-e6}!H zEPR1v?9o}Vpz>;wmkl>g^?jnsVqtQtTzBz&J}VY@KFDZ9ygQ-Mv1qtA64#t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PW@BMLEyvnj_uPPUydywDEs?X*~3rR z!>?-;j=rvCtW3C_qGK6;r<DDPRkrsr+xr?%(4BmxMDWeuYacr3`1M5lFztAFkQyea dhavA!KlQNR&>zv%@B!+P$2;6XJ?b#@e*tamWFr6o literal 0 HcmV?d00001 diff --git a/Other/WeishauptOrlando_2/src/__pycache__/calculator.cpython-312.pyc b/Other/WeishauptOrlando_2/src/__pycache__/calculator.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f0b57fa27c691af261a84626b8e70408fd018db1 GIT binary patch literal 2290 zcmai0UrbY17(b`CEwq3wRjVM5i!y9Mi$mi;af?!%bF(!8T`bj`%RQ%X<@UBa_gsVy z%wk-kPusEwNVX+B?7>AJSh8e3_+Ww$OZIYINzCq8vShyOjSQA7>}BV)y%fxrorLdv z=lk>fzH|D0-{psf20vgcQ@=X)Q7r(!@q@EG6=p5Qm^pv|f*MHi-KD{-E9HW~1>OQk zxC4+IyB-K-`;;&Zqn_XSArXak-P;4QrkI*cb3`dyl&QONSQ8mD2QWxM1X3;pQvz~f zHxjTX<3{c~?v!`h6ZP8uDvo)IxeThhI4m2=IMxYP#&t{%iwF}jE7Nhzh{{#s8Ph;y z>9I0_#Zg?gqcPi$r}6|FhMLoDFTvC#y5g$j!?zmt$FH+C#iVn<2WH?6$Q9ccg2?rt z;x`Lv<pBV=;oNPDITB`|V{6n=9-*|5`#}Zy_ErS;W4yeOr;0%8Xq}@+-YNpiv%!&9 zcU0q8{D;2Q(NDY%0K=|k=W{gMvirCD`K#F(;s1Gyx~lEAX!Tp71)Th6AZkE6RHy={ z#AaQzaZ~G}A%~~C94@o@yD<FSj&#Q5;17W<cMLev+wdTuVaK{1ka`H{9_NgLRXbX0 z8?K>y9X)M!xQxJjTV{nVF&gQ9M>``pIG=+rH#52o(T-W+mT(i^1XIFQa1%yD<_PmS z>y)jCRUPZw>sv1uxT#EtvSx@wl&JccXzEB@dd%uQ&q_Z-McK?S+1S!!jjCf<WSui6 zk77Nx0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W6BUzp7=-4$hVAMaFH^ n_Lq}<gGAYpe?*NYM%bkx{2BOu0Uhh!Lof+H+4m>ld&%`55cy3D literal 0 HcmV?d00001 diff --git a/Other/WeishauptOrlando_2/src/__pycache__/interfaces.cpython-312.pyc b/Other/WeishauptOrlando_2/src/__pycache__/interfaces.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6219bfc375082ce2fd1f73bcfd756ebca8b34d4b GIT binary patch literal 2147 zcmb_d&u<$=6rSC+9mla-(o$5QLPH{vSPE82E+_(|#EBp(N+k$FSe91fofmt>{s=R( zf%w!z4jj3q#~zAA)jR({j{E~?FCcN^W|DB}iT8Hbsb!GDAtUX3Z@-y0`{sRb-u}{P z)EJKa`l$b-!`L76G9Kl^I1kV`VUkHJV4>BqLc3#I%w``mX&*D`fb|@GX>^<nEg@Q- zKuZ}~L3CyUEoW#I(b);Ka#U;1{YjfO?bO-WY^OIwPa7pX6M`AU(xbWYxQy`~L{1p6 zjwM;g21i;@k~Wn0OVT+mJulXGDo3SeIi276+$cZlw?*J3fiSU3XQCwRfzoM3fk{;4 z+2c<Xnof9LLUF>5tfrk{23U<3V?#<Gl;J%HeCYXoe&|C0ydwqyL@OL8xlEKd;1A+3 z6q@(JD2O7%wI9jW<u;!JDB!UK#iK-Vk!ViP5PWX{5$>)Hpdo>8`;k$nPy4{X1toFL z??<ts7+ST<?bZ*35+QDtoot=whvuPgipco#u(jFZ3-7J0uB<IIUpnSFK#wF0F?5V4 zKMEIt=J@H$mAlV~rjmwWU(H~0G^LI67l+<@_X~~r?0zDQ?}7W3A4p&MVRsAk*Csyb z-d}b1wzk|2tugcvBBR~=tKGf5NeBpB>pnCCP~9)V*8`Cpn1?D5k&NBdu2x<bqXD%q zJkYI!qtp>n4)6Sn-WI}CDw<+^#74K+Y~vhFw%eRZtF9Y~5L`E{xo#NCBp|!)y5A%s z$Y&H0pE_8EsY97>;H#pWqi&F>lc<aZt<?)Cj@hr}+atSLZaiKaF;q|1&Pbg*tn%t# zgy-($c@0%v-D$@OWh1q;s?wfU)$leh>YP3u1STud&BPmMBYId)OWR94i6mdzT0*`# z_z{HT`dMxZ4e#zm8Y1l*{}7t3-7Fc;Y&C~Fs@G5yg^;Btt$Gxg3vxI=j<Gd{=5g_P zK}!W`$x?!}sGGFaD<o)1#(=s-)@>56lbB-Q4q+t7YmxyQ8CV=KR8JPqNEHmAl`}w2 z*TBHdozLP>MC~{_#G42z%f$bq;zNw!LGG7z63RGNr$2|j#=D<gKfat_;O3YSz6C=+ z6u}VNOhJLVOGnQyVV?WCqL5q@yI8oxds7j%CTEE^^#%#5>Z>_;i<VAtaE~w&l+tMq zyqp8?KRF<$Yv5pRXQHdu;JX6_*ka=7Y8qJ6%ImmU)bZPNgvngadc_X|u*baoOzRS+ zGiYiwkJ#_k`ju%+%lknrj9NsG=|pnENW6*9WFjrB;`WH4`f2-&R8h=m<;6@+)Ylx* z^OS=x`Q6F-Q+7o%j%d}?H(yjg$lKpXihif~gJb%A6eGv7tl!w;MWtpn9y=Ed)y3VC a)%adtFjN;c6hC;mU3bu4{F|Z5!ubb{(c!27 literal 0 HcmV?d00001 diff --git a/Other/WeishauptOrlando_2/src/__pycache__/string_calculator.cpython-312.pyc b/Other/WeishauptOrlando_2/src/__pycache__/string_calculator.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3598fbabdabad4ddd589f69bedaf1572f553b5e0 GIT binary patch literal 2410 zcmaJ?O-vg{6rNrGVH;xp0u2exCXgm>HW)(!3aXkPoTNVysD=ELI<hvN!7S{qo!NB| z$d;-qs$3~mLwbO=s>-1UA`T_WA(5Ix6*yGt#Su|LS3N{+59Q{Dq*A!FZ?M-GiaL_t zym{}N@4YuO`}}i7g$KcimFHp^7ec?Yg*6-nW#u(cCJ{!MQ;^CHa2(>%8HD+32-^rZ zYs=#X_%XZRvCI~J&a8U7&!Dmv>z0&gQjv@}jpku_X)i2Rc7Za92pZrp8sITUY?vqZ zK|8ixvky2JqglC`$#iK+^)jKl>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i2eV(A=KIR}X*Mn>l^s3}7njp7?}^K4E(MBj5g+)8F^r>b=+fNIbr@YwvV$`u(Z1 z6Yi&LYTML1HyCM6!(?D0Fx@<3TdWo{u62ulrf;!2m~lO=Yn)Uk)amZUx&s++t_<yK z{oBUx^epWb=7M)SZ+G4~`Xhhm*!Auk+@x#5^@aPho*eUMd^rSD&V%-}KCV4F6`Tvs zUAc4Q=6l)NqZv1dU%a)yR`1I0?wB*~j@=$xs9EUy$-j7_f3fpiw&Q%Z@xo&D#ccUS z$Y_7Z<A(0(s(V%U@DDq_3T7L+Gd>W1_^NLlTl6($%bH$3+X1m&KJ%dMT}<u_ae6bH z<b�La*B&9NY<VzT6WE*yro*AQ!fILWk`OJM18P{7$nh644};L?Wgq5>ewgsW81f z61kF;l)Q&R$40b{3C4U2t$;+di3#@CyC&E>)ma<AhH`v|qj{=5hhUm+f6gZAw{Sgv zo4E~MM+<xfgbu=Yp;PwJ<(UpJZ4JxVSIgeWXY?jL2ut>%>h&OUHjd+7I1zW~xwDgN N&ek7zfnZ+S_%Hq_R<{5E literal 0 HcmV?d00001 diff --git a/Other/WeishauptOrlando_2/stringCalculator.py b/Other/WeishauptOrlando_2/stringCalculator.py new file mode 100644 index 0000000..bd21dc8 --- /dev/null +++ b/Other/WeishauptOrlando_2/stringCalculator.py @@ -0,0 +1,88 @@ +from abc import ABC, abstractmethod +import unittest + +class IStringCalculator(ABC): + @abstractmethod + def add(self, numbers: str) -> int: + pass + +class StringCalculator(IStringCalculator): + def add(self, numbers: str) -> int: + if not numbers: + return 0 + + # Überprüfe, ob ein benutzerdefiniertes Trennzeichen angegeben ist + if numbers.startswith("//"): + delimiter_line_end = numbers.find("\n") + delimiter = numbers[2:delimiter_line_end] # Extrahiere das Trennzeichen + numbers = numbers[delimiter_line_end + 1:] # Entferne die erste Zeile mit dem Trennzeichen + else: + delimiter = ',' # Standard-Trennzeichen ist Komma + + # Ersetze alle Vorkommen des Trennzeichens und teile die Eingabe + numbers = numbers.replace("\n", delimiter) + nums = numbers.split(delimiter) + + # Filtere alle Zahlen, die größer als 1000 sind + nums = [int(num) for num in nums if int(num) <= 1000] + + # Prüfe auf negative Zahlen + negatives = [num for num in nums if num < 0] + + if negatives: + # Wenn negative Zahlen vorhanden sind, werfe eine Ausnahme + raise ValueError(f"Negatives not allowed: {', '.join(map(str, negatives))}") + + # Berechne die Summe der Zahlen, die <= 1000 sind + return sum(nums) + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + self.calculator = StringCalculator() + + def test_empty_string(self): + self.assertEqual(self.calculator.add(""), 0) + + def test_single_number(self): + self.assertEqual(self.calculator.add("1"), 1) + + def test_two_numbers(self): + self.assertEqual(self.calculator.add("1,2"), 3) + + def test_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3,4,5"), 15) + + def test_numbers_with_newline(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + + def test_numbers_with_multiple_newlines(self): + self.assertEqual(self.calculator.add("1\n2\n3\n4\n5"), 15) + + def test_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + self.assertEqual(str(context.exception), "Negatives not allowed: -2") + + def test_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,-3,4") + self.assertEqual(str(context.exception), "Negatives not allowed: -2, -3") + + def test_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + + def test_custom_delimiter_with_newline(self): + self.assertEqual(self.calculator.add("//;\n1;2\n3"), 6) + + def test_custom_delimiter_with_multiple_numbers(self): + self.assertEqual(self.calculator.add("//|\n1|2|3|4"), 10) + + def test_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + + def test_numbers_greater_than_1000_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n2;1001"), 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/Other/WeishauptOrlando_2/your_calculator.py b/Other/WeishauptOrlando_2/your_calculator.py new file mode 100644 index 0000000..967500c --- /dev/null +++ b/Other/WeishauptOrlando_2/your_calculator.py @@ -0,0 +1,74 @@ +#Meine Implementierungen auf Testfälle anderer Studierenden testen: StringCalculator + +import unittest +from stringCalculator import StringCalculator + +class TestStringCalculator(unittest.TestCase): + def setUp(self): + # Vor jedem Test wird eine Instanz des Calculators erstellt + self.calc = StringCalculator() + + def test_implements_interface(self): + self.assertIsInstance(self.calc, StringCalculator) + + def test_add_empty_string(self): + # Leerer String → 0 + self.assertEqual(self.calc.add(""), 0) + + def test_add_single_number(self): + # Ein einzelner Wert → int + self.assertEqual(self.calc.add("1"), 1) + + def test_add_two_numbers(self): + # Zwei Zahlen → Summe + self.assertEqual(self.calc.add("1,2"), 3) + + def test_add_multiple_numbers(self): + # Mehr als zwei Zahlen → Summe + self.assertEqual(self.calc.add("1,2,3"), 6) + self.assertEqual(self.calc.add("1,2,3,4,5"), 15) + + def test_add_ignores_empty_entries(self): + # Leere Einträge ignorieren → Summe + self.assertEqual(self.calc.add("1,,2"), 3) + self.assertEqual(self.calc.add("1, ,2"), 3) + self.assertEqual(self.calc.add(",,1,,2,,,"), 3) + + def test_add_with_newlines_between_numbers(self): + # Zeilenumbrüche als Trennzeichen erlauben → Summe + self.assertEqual(self.calc.add("1\n2,3"), 6) + self.assertEqual(self.calc.add("1,2\n3"), 6) + self.assertEqual(self.calc.add("1\n2\n3"), 6) + + def test_add_raises_exception_on_negative_number(self): + # Negative Zahlen → Exception mit allen negativen Werten + with self.assertRaises(ValueError) as context: + self.calc.add("1,-2") + self.assertIn("negatives not allowed: -2", str(context.exception)) + + def test_add_raises_exception_on_multiple_negatives(self): + # Negative Zahlen → Exception mit allen negativen Werten + with self.assertRaises(ValueError) as context: + self.calc.add("-1,-2,3") + self.assertIn("negatives not allowed: -1, -2", str(context.exception)) + + def test_add_with_custom_delimiter(self): + # Benutzerdefinierter Delimiter über Präfix: "//<delimiter>\n" + self.assertEqual(self.calc.add("//;\n1;2"), 3) + self.assertEqual(self.calc.add("//|\n4|5|6"), 15) + self.assertEqual(self.calc.add("//_\n7_8_9"), 24) + + def test_add_ignores_numbers_greater_than_1000(self): + # Zahlen größer als 1000 ignorieren + self.assertEqual(self.calc.add("2,1001"), 2) + self.assertEqual(self.calc.add("1000,1"), 1001) + self.assertEqual(self.calc.add("1234,1001,3"), 3) + + def test_add_with_multi_char_delimiter(self): + # Delimiter mit beliebiger Länge (Format: //[delimiter]\n) + self.assertEqual(self.calc.add("//[***]\n1***2***3"), 6) + self.assertEqual(self.calc.add("//[abc]\n4abc5abc6"), 15) + self.assertEqual(self.calc.add("//[+]\n1+2+3"), 6) + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index e55739a..0000000 --- a/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# ModernDev - - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.reutlingen-university.de/Hatice.Yildirim/moderndev.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.reutlingen-university.de/Hatice.Yildirim/moderndev/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. -- GitLab