From dcd5a64df7c284bf49d3e4c61f502f983a19a6cd Mon Sep 17 00:00:00 2001 From: Hatice Yildirim <Hatice.Yildirim@student.reutlingen-university.de> Date: Sat, 5 Apr 2025 01:48:52 +0200 Subject: [PATCH 1/5] Meine Implementierung converter.py --- Other/PikkemaatLasse_1/converter.py | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Other/PikkemaatLasse_1/converter.py diff --git a/Other/PikkemaatLasse_1/converter.py b/Other/PikkemaatLasse_1/converter.py new file mode 100644 index 0000000..0ef9bd0 --- /dev/null +++ b/Other/PikkemaatLasse_1/converter.py @@ -0,0 +1,49 @@ +#Bei Eingabe von Zahlen, die in der Liste definiert sind, sollen römische Zhalen zurückgegeben werden. +#Bei Eingabe von Zahlen, die nicht in der Liste definiert ist, soll ein "" ausgeben werden. + +import unittest +from abc import ABC, abstractmethod + +class IRomanNumber(ABC): + @abstractmethod + def convert(self, n:int) -> str: + pass + +class RomanNumber(IRomanNumber): + def convert(self, n: int) -> str: + roman_numerals = { + 1: "I", 2: "II", 3: "III", + 4: "IV", 5: "V", 9: "IX", + 21: "XXI", 50: "L", 100: "C", + 500: "D", 1000: "M" + } + return roman_numerals.get(n, "") + +class TestRomanConverter(unittest.TestCase): + def setUp(self): + self.converter = RomanNumber() + + def test_single_value(self): + self.assertEqual(self.converter.convert(1), "I") + self.assertEqual(self.converter.convert(2), "II") + self.assertEqual(self.converter.convert(3), "III") + self.assertEqual(self.converter.convert(4), "IV") + self.assertEqual(self.converter.convert(5), "V") + self.assertEqual(self.converter.convert(9), "IX") + self.assertEqual(self.converter.convert(21), "XXI") + self.assertEqual(self.converter.convert(50), "L") + self.assertEqual(self.converter.convert(100), "C") + self.assertEqual(self.converter.convert(500), "D") + self.assertEqual(self.converter.convert(1000), "M") + + def test_inivalid_numbers(self): + self.assertEqual(self.converter.convert(6), "") + self.assertEqual(self.converter.convert(99), "") + self.assertEqual(self.converter.convert(-1), "") + + + + + +if __name__ == "__main__": + unittest.main() -- GitLab From ddf830eaa9b81c3dcad0d8d700c01852bece715c Mon Sep 17 00:00:00 2001 From: Hatice Yildirim <Hatice.Yildirim@student.reutlingen-university.de> Date: Sat, 5 Apr 2025 08:45:08 +0200 Subject: [PATCH 2/5] Interfaces von PikkemaatLasse --- Other/PikkemaatLasse_1/src/README.md | 93 ++++++++++++++++++ Other/PikkemaatLasse_1/src/Test.py | 2 + Other/PikkemaatLasse_1/src/__init__.py | 0 .../src/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 142 bytes .../src/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 211 bytes .../__pycache__/interfaces.cpython-310.pyc | Bin 0 -> 505 bytes .../__pycache__/interfaces.cpython-312.pyc | Bin 0 -> 613 bytes .../__pycache__/romannumerals.cpython-310.pyc | Bin 0 -> 894 bytes .../__pycache__/romannumerals.cpython-312.pyc | Bin 0 -> 1159 bytes Other/PikkemaatLasse_1/src/calculator.py | 29 ++++++ Other/PikkemaatLasse_1/src/counter.py | 48 +++++++++ Other/PikkemaatLasse_1/src/interfaces.py | 6 ++ Other/PikkemaatLasse_1/src/main.py | 0 Other/PikkemaatLasse_1/src/romannumerals.py | 23 +++++ 14 files changed, 201 insertions(+) create mode 100644 Other/PikkemaatLasse_1/src/README.md create mode 100644 Other/PikkemaatLasse_1/src/Test.py create mode 100644 Other/PikkemaatLasse_1/src/__init__.py create mode 100644 Other/PikkemaatLasse_1/src/__pycache__/__init__.cpython-310.pyc create mode 100644 Other/PikkemaatLasse_1/src/__pycache__/__init__.cpython-312.pyc create mode 100644 Other/PikkemaatLasse_1/src/__pycache__/interfaces.cpython-310.pyc create mode 100644 Other/PikkemaatLasse_1/src/__pycache__/interfaces.cpython-312.pyc create mode 100644 Other/PikkemaatLasse_1/src/__pycache__/romannumerals.cpython-310.pyc create mode 100644 Other/PikkemaatLasse_1/src/__pycache__/romannumerals.cpython-312.pyc create mode 100644 Other/PikkemaatLasse_1/src/calculator.py create mode 100644 Other/PikkemaatLasse_1/src/counter.py create mode 100644 Other/PikkemaatLasse_1/src/interfaces.py create mode 100644 Other/PikkemaatLasse_1/src/main.py create mode 100644 Other/PikkemaatLasse_1/src/romannumerals.py diff --git a/Other/PikkemaatLasse_1/src/README.md b/Other/PikkemaatLasse_1/src/README.md new file mode 100644 index 0000000..e483d0f --- /dev/null +++ b/Other/PikkemaatLasse_1/src/README.md @@ -0,0 +1,93 @@ +# PraxisprojektTechnologiebasierteInnovation + + + +## 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/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: + +``` +cd existing_repo +git remote add origin https://gitlab.reutlingen-university.de/Lasse.Pikkemaat/praxisprojekttechnologiebasierteinnovation.git +git branch -M main +git push -uf origin main +``` + +## Integrate with your tools + +- [ ] [Set up project integrations](https://gitlab.reutlingen-university.de/Lasse.Pikkemaat/praxisprojekttechnologiebasierteinnovation/-/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/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) + +## 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. diff --git a/Other/PikkemaatLasse_1/src/Test.py b/Other/PikkemaatLasse_1/src/Test.py new file mode 100644 index 0000000..903e6d7 --- /dev/null +++ b/Other/PikkemaatLasse_1/src/Test.py @@ -0,0 +1,2 @@ +print("Hello WORLD") +print("test") \ No newline at end of file diff --git a/Other/PikkemaatLasse_1/src/__init__.py b/Other/PikkemaatLasse_1/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Other/PikkemaatLasse_1/src/__pycache__/__init__.cpython-310.pyc b/Other/PikkemaatLasse_1/src/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4155c6cc3f22b5cdf03255ec978f442867072db GIT binary patch literal 142 zcmd1j<>g`kf(cjdri19mAOaaM0yz#qT+9L_QW%06G#UL?G8BP?5yUS;XRDatlG2pS z(%hJUqQr{K;)0_5tkmoh-~5!+qCA(>vY6tc<e2#Q%)HE!_;|g7%3B;Zx%nxjIjMFa Lql%e;1PcQIlj9)p literal 0 HcmV?d00001 diff --git a/Other/PikkemaatLasse_1/src/__pycache__/__init__.cpython-312.pyc b/Other/PikkemaatLasse_1/src/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d52e19498fdc85fe8aa4a3361ed595bcbaaabd81 GIT binary patch literal 211 zcmX@j%ge<81Z%lJq=V?kAOanHW&w&!XQ*V*Wb|9fP{ah}eFmxdRg`QM6Iz^FR2<`x zSdy8X8XuXNlag7KnH%GhTAW>yUl3zp6d&T^67N`CoSB}No0?Zr9B*J06B2?flnN3w zj`1(aNG*y9$jr`8%}q=!@kuN$PK`H=DK1KmiI30B%PfhH*DI*}#bJ}1pHiBWYFESx UbOIv~7lRldnHd=wi<p5d0LbJ!TL1t6 literal 0 HcmV?d00001 diff --git a/Other/PikkemaatLasse_1/src/__pycache__/interfaces.cpython-310.pyc b/Other/PikkemaatLasse_1/src/__pycache__/interfaces.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..95e7981751754055c5e10944cc00468b50941e10 GIT binary patch literal 505 zcmY*Vy-ou$49?FL9Tlw@kl+DWx^!Vf2o;Ki7&sxiolc6<OA3X{r6hNVGSa>b55y9Q ziHTQW!oI4aSh8cspY6}Kolcv8%s)Qw-r)VhU{fLp2B7{Bj3SB_#L$!)mNH5%iDHT` ziQ<|rc*<2YBE8l(AW4q}es(?#T{-rZlX+!yb#GOUxlQ2^3_$$>7)?^DNXj%<RIw#l z&@@sUdPbppb!&|*liFw}3!gK9uLXSyIt2AdSP`h9$vd)$ye=kzm$h*%NHyl?Xn35B zs#;BJlifJ^GW9cOAM|5&ZIyQAg?`Sw%d=@&X*ZF%_WjvB#FZ5eN#F>NLnHRO|DRWX zjY)c~5DQUCqlE}<A&gaZf&PvVPqi#o8HfA3?KQDKiY~@KoP-F!1tunpc4_mMz(u$m d=MGt{dLVS8yxA3dg!p7N`V>#poM)Hpv0o*tY}5b% literal 0 HcmV?d00001 diff --git a/Other/PikkemaatLasse_1/src/__pycache__/interfaces.cpython-312.pyc b/Other/PikkemaatLasse_1/src/__pycache__/interfaces.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4f1e7f4f14f8dc3715ac6481cb4ba3ee057810a3 GIT binary patch literal 613 zcmY*VL2DE-82ysWl%d_}K?}WjD0mtVrPiB>P+h16Sw+`_Lm;FxX*=v>rcJVkEfhTL z59qDGL5jb`KOl2a@Z_yBdg;l0GrM2|d3j&H_dQ<nHI7%ouP<vi#~1$miN$h-3(`LF z<O*`gNeP;yMAMWKps)`)okPwPxn{jKWwRg&e_@f(hV8w0*{sV$>x|5tR_>(EvtHOE zT@>vDPp&{gN^(f4VmX<^^`e;uGn%kw{oq}#Wi^^=Wn^iy<?KQQn4k?hpBW@%^cfQb zR+UE$tESqberxO2Wl#ABtBmEZq$@HdJ{DzOm_qZRvJ+RI@||5V9uCExwZ(CzRpqSM z+2!N$|5pkxpYS*CL>d0Jm`s$G(!G|}D)E?GlkuW*${fi|+3nL=6S-O#jDNm)_Zi#E z1}3-o<DcM1G-y46Q4%(h5S7$Qh-Os?UFXvh`9O%XsVw`B!BI0nh!A3gHH4KV;NRE{ z4|Dhy-v3QW7`F^oHagZ1pmvl54U>nNL49xAS=_a~jh^*Eo|}7KNBr)*Zx|uuJ3Rao OFcM$B{|o-;y#E2$GLq8( literal 0 HcmV?d00001 diff --git a/Other/PikkemaatLasse_1/src/__pycache__/romannumerals.cpython-310.pyc b/Other/PikkemaatLasse_1/src/__pycache__/romannumerals.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f6197cf9b2af49383222064fa3d7a160c943eea6 GIT binary patch literal 894 zcmY+CPiqrF7{=$%ZkmRqDnt*0uxbVO5~zY25fRcN0UN|ZDNAHoGt*@4?rb}=TW#2Y zn0^31f_U=-c^UB3i@kgDAinR$LORR5^P6X8o_Tj>vR11>pq%{pIX+{AoMC6VIM8_k z)p!sD5i}tw4JaiqiC}`C62T>%^MDCwhxqO}%pyLuYyCG_8mU2%N*yI;gz|EMtroUz z07(KW2v|_TPD#K82P?<6E?eM|i&6vNP<v3#1VT<qn$tNmt2x-r>1SGk*#R}zpyday zz7D#B`j`m!8=WyxoAHuulDF+4n>jPLq@@G%HcDQ)j|q%H{|T9a59;RL(XA5GS{Y1l zZ^ddHy^~&A7~{!UNpBpfsq}(ql6VFLO(CWD>lH$#>y=o|oPLPSXd;!j;T1}F54+v2 zm&9@`mEZDN{0n}_(rutqB-TUx4NjJB0)0VZJ-~AT?w0m|0wlJF_@EMB0o`ASh<LY_ z?g6b<Vjt11#9bh~T+8~1n6agOOMGq{v5A$*BQ=ti$11mt-6$#Kme!f}Yt}I`*$=oX zQp=B{#MZPlMUq<=I)w~YU;r=uJJEN*^v|Q-)8S5Dh`30HuXXe>HitTUFAwtVOh~OZ z<?+zy(NN=i`M=b34o_@7&%#Q?e9cV=4O*vHq1KtR(!>_OzwDF4r#CLWmCnV|0X(C6 z7^*0hVQ3p+m}a6#kegw6R7A;QM6ZK;mF-fviyGVn!Ba9A>ZD04W#IE*4U+D_;Yht7 ejik}|JgdPa3;chLKDPdBvGa30=gO=}+Wa5JLfq#7 literal 0 HcmV?d00001 diff --git a/Other/PikkemaatLasse_1/src/__pycache__/romannumerals.cpython-312.pyc b/Other/PikkemaatLasse_1/src/__pycache__/romannumerals.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8fbaca8987e1e2f9e658eb47bf046adee636b5f1 GIT binary patch literal 1159 zcmY+D&ube;6vyA}?8=TT*+PyL+QzWPCFw%yCe9@erPNp<HKb~3osfzR%T_y)7wxXn zncW1d5|rYDDL$w_z&i9$dMl=v{u`y>kRHU4o_a}cB1$hg_06v3By)KCneTh^X6C)w zKa0gY;P`!J)ci{W_*YFP!#IZVIfMi7z#{>Kq)rHEa2-5t7d*<yA<g3I+Kz4+Pu0XC za(45xcIZa6BxKwTL?esIEIFQx%LoU+piVrfYaZE!I^EGMDvPf##*>{49ZBst{sYYc z#FJ#uCGknz;W3GscybFo{o!%!x1>uvt@S2=Fpy}=2H>wo>MtXk;2FP?p62Cxw5wI& z&RYOBX7A}eT-(*vT0!;;UD`D|MbxQMJ7<t^m(0(}erbPEhc5jbtf^XO>6#xk-7lFL zCPJ9ZkC@qXqYg9c?si}b6u3IS|H~Xe=j~KXBRda#(b#5@dC5#7&%C_0wq^!CYqH2H zTAKd^%Oc6gNV|%(4TaC~&XQD-`iis-#HSu+mt+H}u1LGBa5WWgAia}`3f1e7<Tlc& zRNPdkN-D`MB-IS5Z7Ni?m1I)_wlD7sKN7JUHJGG+6wCZAH%Qnu&fDC|NnNnuuB1^C zN_yW7WR5eD1hF)5k}x@ij`Y#wFr}G}7Y`a&?VEyeVSnVteuFt*_<`qhKeVe%wBq(X z`{JszRjoSfLio)nWKk@fi>vn5)~gaz;${1jc$;ziQ@_<>q3gysTp^fq$rij}bM<H^ z`>)*Fk<)S8NySd(wKusk(N!@-56w65c<znC^3US$x#h>@vqy^`J}R#t71oC{v;C#- zuJpyg`{C=<vGJ%}Jt|b6>Bd}skB(-ce0nc8G?$+NJ+=6-aCYxz|N5}JFj)BU!mv~s zoPSta>gR@~`F`?!p-)E!%vS~rKV2A63?EHHsj^ob;{l*%>2lg}A~$4?BlC_Ew!I`! zTyUJP5;w>^T=n-i;1+)Pd1cfcQlt7QrqJxdSSuTqEJnF&*w$IB&<eJb@w;w=39f#_ rZ0);>PV&8&em~p!1O6U5)XNa3(Tpe|<R7q}=jKVJU;7X6ldk$71idTV literal 0 HcmV?d00001 diff --git a/Other/PikkemaatLasse_1/src/calculator.py b/Other/PikkemaatLasse_1/src/calculator.py new file mode 100644 index 0000000..e799761 --- /dev/null +++ b/Other/PikkemaatLasse_1/src/calculator.py @@ -0,0 +1,29 @@ +#Test1: Addition 2 positiver Zaheln (2+5) erwartetes Ergebnis 8 +#Test2: Addition negativer und positiver Zahl (-1+1) erwartetes Ergebnis 0 +#Test3: Addition (0+0), erwartetes Ergebnis 0 +#Test4: Addition von 2 Dezimalzahlen (2,5+3,5), erwartetes Ergebnis 6 + +from abc import ABC, abstractmethod +class ICalculator(ABC): + @abstractmethod + def add(self, a: float, b: float) -> float: + pass + +class Calculator(ICalculator): + def add(self, a: float, b: float) -> float: + return a + b + +class TestCalculator: + def __init__(self, calculator: ICalculator): + self.calculator = calculator + def test_add(self): + assert self.calculator.add(2,3) == 5, "Fehler falls nicht 5" + assert self.calculator.add(-1,1) == 0, "Fegler falls nich 0" + assert self.calculator.add(0,0) == 0, "Fehler falls nicht 0" + assert self.calculator.add(2.5,3.5) == 6, "Fehler falls nicht 5" + print("Test erfolgreich") + +if __name__ == "__main__": + calc = Calculator() + tester = TestCalculator(calc) + tester.test_add() diff --git a/Other/PikkemaatLasse_1/src/counter.py b/Other/PikkemaatLasse_1/src/counter.py new file mode 100644 index 0000000..00cf9c0 --- /dev/null +++ b/Other/PikkemaatLasse_1/src/counter.py @@ -0,0 +1,48 @@ +#Bei Eingabe des Strings "Decker" liefert die Funktion 3 +#Bei Eingabe eines leeren Stings soll 0 augegeben werden +#Bei Eingabe des Strings "Hallo" ohne E und D soll 0 ausgegeben werden +#Bei Eingabe von dem String "Der Esel" soll Groß-Kleinschreibung (Caseinsensitive) gezählt werden. das Ergebnis ist 4 +#Bei Eingabe des Buchstaben D oder E soll 1 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): + s=s.upper() + return s.count("D")+s.count("E") + +class TestCounter (unittest.TestCase): + def setUp(self): + self.c=Counter() + def test_count_ED_regular (self): + res=self.c.count_ED ("Decker") + self.assertEqual(res,3) + def test_count_ED_empty (self): + res=self.c.count_ED ("") + self.assertEqual(res,0) + def test_count_ED_wo (self): + '''Testet einen String ohne E und D''' + res=self.c.count_ED ("Hallo") + self.assertEqual(res,0) + def test_count_ED_case_insensitive (self): + '''Testet verschiedene Groß- und Kleinschreibungen''' + res=self.c.count_ED ("Der Esel") + self.assertEqual(res,4) + def test_count_ED_single_letetr (self): + '''Testet Eingaben mit nur einem Buchstaben''' + res=self.c.count_ED ('D') + self.assertEqual(res,1) + res=self.c.count_ED ('E') + self.assertEqual (res,1) + res=self.c.count_ED ('d') + self.assertEqual(res,1) + res=self.c.count_ED ('e') + self.assertEqual (res,1) +if __name__=="__main__": + unittest.main() \ No newline at end of file diff --git a/Other/PikkemaatLasse_1/src/interfaces.py b/Other/PikkemaatLasse_1/src/interfaces.py new file mode 100644 index 0000000..fc64573 --- /dev/null +++ b/Other/PikkemaatLasse_1/src/interfaces.py @@ -0,0 +1,6 @@ +from abc import ABC, abstractmethod + +class IRomanNumerals(ABC): + @abstractmethod + def to_roman(self, num): + pass \ No newline at end of file diff --git a/Other/PikkemaatLasse_1/src/main.py b/Other/PikkemaatLasse_1/src/main.py new file mode 100644 index 0000000..e69de29 diff --git a/Other/PikkemaatLasse_1/src/romannumerals.py b/Other/PikkemaatLasse_1/src/romannumerals.py new file mode 100644 index 0000000..3f3eaf1 --- /dev/null +++ b/Other/PikkemaatLasse_1/src/romannumerals.py @@ -0,0 +1,23 @@ +from src.interfaces import IRomanNumerals + + +class RomanNumerals(IRomanNumerals): + def to_roman(self, num): + if not isinstance(num, int): + raise ValueError("Eingabe muss eine ganze Zahl sein") + if num <= 0 or num >= 4000: + raise ValueError("Zahl muss zwischen 1 und 3999 liegen") + + val = [ + (1000, "M"), (900, "CM"), (500, "D"), (400, "CD"), + (100, "C"), (90, "XC"), (50, "L"), (40, "XL"), + (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), + (1, "I") + ] + + result = "" + for (value, numeral) in val: + while num >= value: + result += numeral + num -= value + return result \ No newline at end of file -- GitLab From 83fbc2dcb59a239624d8e47903274877874ea2b1 Mon Sep 17 00:00:00 2001 From: Hatice Yildirim <Hatice.Yildirim@student.reutlingen-university.de> Date: Sat, 5 Apr 2025 08:49:30 +0200 Subject: [PATCH 3/5] Tests von PikkemaatLasse --- .../tests/test_romannumerals.py | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 Other/PikkemaatLasse_1/tests/test_romannumerals.py diff --git a/Other/PikkemaatLasse_1/tests/test_romannumerals.py b/Other/PikkemaatLasse_1/tests/test_romannumerals.py new file mode 100644 index 0000000..9a774cc --- /dev/null +++ b/Other/PikkemaatLasse_1/tests/test_romannumerals.py @@ -0,0 +1,108 @@ +# Basisfälle +# Bei Eingabe der Zahl 1, erhalte ich das Ergebnis I +# Bei Eingabe der Zahl 5, erhalte ich das Ergebnis V +# Bei Eingabe der Zahl 10, erhalte ich das Ergebnis X +# Bei Eingabe der Zahl 50, erhalte ich das Ergebnis L +# Bei Eingabe der Zahl 100, erhalte ich das Ergebnis C +# Bei Eingabe der Zahl 500, erhalte ich das Ergebnis D +# Bei Eingabe der Zahl 1000, erhalte ich das Ergebnis M +# Substraktionsregel +# Bei Eingabe der Zahl 4, erhalte ich das Ergebnis IV +# Bei Eingabe der Zahl 9, erhalte ich das Ergebnis IX +# Bei Eingabe der Zahl 40, erhalte ich das Ergebnis XL +# Bei Eingabe der Zahl 90, erhalte ich das Ergebnis XC +# Bei Eingabe der Zahl 400, erhalte ich das Ergebnis CD +# Bei Eingabe der Zahl 900, erhalte ich das Ergebnis CM +# Additionsregel +# Bei Eingabe der Zahl 2 erhalte ich das Ergebnis "II" +# Bei Eingabe der Zahl 3 erhalte ich das Ergebnis "III" +# Bei Eingabe der Zahl 6 erhalte ich das Ergebnis "VI" +# Bei Eingabe der Zahl 8 erhalte ich das Ergebnis "VIII" +# Bei Eingabe der Zahl 30 erhalte ich das Ergebnis "XXX" +# Bei Eingabe der Zahl 80 erhalte ich das Ergebnis "LXXX" +# Kombination aus Addition und Subtraktion +# Bei Eingabe der Zahl 14 erhalte ich das Ergebnis "XIV" +# Bei Eingabe der Zahl 19 erhalte ich das Ergebnis "XIX" +# Bei Eingabe der Zahl 29 erhalte ich das Ergebnis "XXIX" +# Bei Eingabe der Zahl 44 erhalte ich das Ergebnis "XLIV" +# Bei Eingabe der Zahl 99 erhalte ich das Ergebnis "XCIX" +# Bei Eingabe der Zahl 444 erhalte ich das Ergebnis "CDXLIV" +# Bei Eingabe der Zahl 999 erhalte ich das Ergebnis "CMXCIX" +# Größere Zahlen +# Bei Eingabe der Zahl 1001 erhalte ich das Ergebnis "MI" +# Bei Eingabe der Zahl 1987 erhalte ich das Ergebnis "MCMLXXXVII" +# Bei Eingabe der Zahl 2023 erhalte ich das Ergebnis "MMXXIII" +# Bei Eingabe der Zahl 3999 erhalte ich das Ergebnis "MMMCMXCIX" +# Fehlerfälle +# Bei Eingabe der Zahl 0 erhalte ich eine Fehlermeldung +# Bei Eingabe der Zahl -1 erhalte ich eine Fehlermeldung +# Bei Eingabe der Zahl 4000 erhalte ich eine Fehlermeldung +# Bei Eingabe der Zeichenfolge "ABC" erhalte ich eine Fehlermeldung +# Bei Eingabe von None erhalte ich eine Fehlermeldung +# Bei Eingabe der Zahl 3.14 erhalte ich eine Fehlermeldung + +import unittest +from src.romannumerals import RomanNumerals + + +class TestRomanNumerals(unittest.TestCase): + def setUp(self): + self.converter = RomanNumerals() + + def test_to_roman_basic(self): + self.assertEqual(self.converter.to_roman(1), "I") + self.assertEqual(self.converter.to_roman(5), "V") + self.assertEqual(self.converter.to_roman(10), "X") + self.assertEqual(self.converter.to_roman(50), "L") + self.assertEqual(self.converter.to_roman(100), "C") + self.assertEqual(self.converter.to_roman(500), "D") + self.assertEqual(self.converter.to_roman(1000), "M") + + def test_to_roman_subtraction(self): + self.assertEqual(self.converter.to_roman(4), "IV") + self.assertEqual(self.converter.to_roman(9), "IX") + self.assertEqual(self.converter.to_roman(40), "XL") + self.assertEqual(self.converter.to_roman(90), "XC") + self.assertEqual(self.converter.to_roman(400), "CD") + self.assertEqual(self.converter.to_roman(900), "CM") + + def test_to_roman_addition(self): + self.assertEqual(self.converter.to_roman(2), "II") + self.assertEqual(self.converter.to_roman(3), "III") + self.assertEqual(self.converter.to_roman(6), "VI") + self.assertEqual(self.converter.to_roman(8), "VIII") + self.assertEqual(self.converter.to_roman(30), "XXX") + self.assertEqual(self.converter.to_roman(80), "LXXX") + + def test_to_roman_mixed(self): + self.assertEqual(self.converter.to_roman(14), "XIV") + self.assertEqual(self.converter.to_roman(19), "XIX") + self.assertEqual(self.converter.to_roman(29), "XXIX") + self.assertEqual(self.converter.to_roman(44), "XLIV") + self.assertEqual(self.converter.to_roman(99), "XCIX") + self.assertEqual(self.converter.to_roman(444), "CDXLIV") + self.assertEqual(self.converter.to_roman(999), "CMXCIX") + + def test_to_roman_large_numbers(self): + self.assertEqual(self.converter.to_roman(1001), "MI") + self.assertEqual(self.converter.to_roman(1987), "MCMLXXXVII") + self.assertEqual(self.converter.to_roman(2023), "MMXXIII") + self.assertEqual(self.converter.to_roman(3999), "MMMCMXCIX") + + def test_to_roman_invalid(self): + with self.assertRaises(ValueError): + self.converter.to_roman(0) + with self.assertRaises(ValueError): + self.converter.to_roman(-1) + with self.assertRaises(ValueError): + self.converter.to_roman(4000) + with self.assertRaises(ValueError): + self.converter.to_roman("ABC") + with self.assertRaises(ValueError): + self.converter.to_roman(None) + with self.assertRaises(ValueError): + self.converter.to_roman(3.14) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file -- GitLab From 925d8accae56f7d20ac28706d017b329aaee951a Mon Sep 17 00:00:00 2001 From: Hatice Yildirim <Hatice.Yildirim@student.reutlingen-university.de> Date: Sat, 5 Apr 2025 08:53:02 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Implementierung=20von=20PikkemaatLasse=20mi?= =?UTF-8?q?t=20meinen=20Testf=C3=A4llen=20getestet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Other/PikkemaatLasse_1/my_converter.py | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Other/PikkemaatLasse_1/my_converter.py diff --git a/Other/PikkemaatLasse_1/my_converter.py b/Other/PikkemaatLasse_1/my_converter.py new file mode 100644 index 0000000..4ed20d9 --- /dev/null +++ b/Other/PikkemaatLasse_1/my_converter.py @@ -0,0 +1,36 @@ +#Umsetzungen von PikkemaatLasse auf meine Testfälle + +import unittest + +from src.romannumerals import RomanNumerals as RomanNumber +from src.interfaces import IRomanNumerals + + +class TestRomanConverter(unittest.TestCase): + def setUp(self): + self.converter = RomanNumber() + + def test_implements_interface(self): + self.assertIsInstance(self.converter, IRomanNumerals) + + def test_single_value(self): + self.assertEqual(self.converter.convert(1), "I") + self.assertEqual(self.converter.convert(2), "II") + self.assertEqual(self.converter.convert(3), "III") + self.assertEqual(self.converter.convert(4), "IV") + self.assertEqual(self.converter.convert(5), "V") + self.assertEqual(self.converter.convert(9), "IX") + self.assertEqual(self.converter.convert(21), "XXI") + self.assertEqual(self.converter.convert(50), "L") + self.assertEqual(self.converter.convert(100), "C") + self.assertEqual(self.converter.convert(500), "D") + self.assertEqual(self.converter.convert(1000), "M") + + def test_inivalid_numbers(self): + self.assertEqual(self.converter.convert(6), "") + self.assertEqual(self.converter.convert(99), "") + self.assertEqual(self.converter.convert(-1), "") + + +if __name__ == "__main__": + unittest.main() -- GitLab From 1596c4139a062371e6d20ec10f3da8df1beea1d9 Mon Sep 17 00:00:00 2001 From: Hatice Yildirim <Hatice.Yildirim@student.reutlingen-university.de> Date: Sat, 5 Apr 2025 08:56:17 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Meine=20Implementierung=20mit=20PikkemaatLa?= =?UTF-8?q?sse=20Testf=C3=A4llen=20getestet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Other/PikkemaatLasse_1/your_converter.py | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Other/PikkemaatLasse_1/your_converter.py diff --git a/Other/PikkemaatLasse_1/your_converter.py b/Other/PikkemaatLasse_1/your_converter.py new file mode 100644 index 0000000..07ad1bf --- /dev/null +++ b/Other/PikkemaatLasse_1/your_converter.py @@ -0,0 +1,69 @@ +import unittest + +from converter import RomanNumber +from converter import IRomanNumber + +class TestRomanNumerals(unittest.TestCase): + def setUp(self): + self.converter = RomanNumber() + + def test_implements_interface(self): + self.assertIsInstance(self.converter, IRomanNumber) + + def test_to_roman_basic(self): + self.assertEqual(self.converter.to_roman(1), "I") + self.assertEqual(self.converter.to_roman(5), "V") + self.assertEqual(self.converter.to_roman(10), "X") + self.assertEqual(self.converter.to_roman(50), "L") + self.assertEqual(self.converter.to_roman(100), "C") + self.assertEqual(self.converter.to_roman(500), "D") + self.assertEqual(self.converter.to_roman(1000), "M") + + def test_to_roman_subtraction(self): + self.assertEqual(self.converter.to_roman(4), "IV") + self.assertEqual(self.converter.to_roman(9), "IX") + self.assertEqual(self.converter.to_roman(40), "XL") + self.assertEqual(self.converter.to_roman(90), "XC") + self.assertEqual(self.converter.to_roman(400), "CD") + self.assertEqual(self.converter.to_roman(900), "CM") + + def test_to_roman_addition(self): + self.assertEqual(self.converter.to_roman(2), "II") + self.assertEqual(self.converter.to_roman(3), "III") + self.assertEqual(self.converter.to_roman(6), "VI") + self.assertEqual(self.converter.to_roman(8), "VIII") + self.assertEqual(self.converter.to_roman(30), "XXX") + self.assertEqual(self.converter.to_roman(80), "LXXX") + + def test_to_roman_mixed(self): + self.assertEqual(self.converter.to_roman(14), "XIV") + self.assertEqual(self.converter.to_roman(19), "XIX") + self.assertEqual(self.converter.to_roman(29), "XXIX") + self.assertEqual(self.converter.to_roman(44), "XLIV") + self.assertEqual(self.converter.to_roman(99), "XCIX") + self.assertEqual(self.converter.to_roman(444), "CDXLIV") + self.assertEqual(self.converter.to_roman(999), "CMXCIX") + + def test_to_roman_large_numbers(self): + self.assertEqual(self.converter.to_roman(1001), "MI") + self.assertEqual(self.converter.to_roman(1987), "MCMLXXXVII") + self.assertEqual(self.converter.to_roman(2023), "MMXXIII") + self.assertEqual(self.converter.to_roman(3999), "MMMCMXCIX") + + def test_to_roman_invalid(self): + with self.assertRaises(ValueError): + self.converter.to_roman(0) + with self.assertRaises(ValueError): + self.converter.to_roman(-1) + with self.assertRaises(ValueError): + self.converter.to_roman(4000) + with self.assertRaises(ValueError): + self.converter.to_roman("ABC") + with self.assertRaises(ValueError): + self.converter.to_roman(None) + with self.assertRaises(ValueError): + self.converter.to_roman(3.14) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file -- GitLab