From 26229fcc6c432818e91ae0f74e010f1d1bd636ec Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Mon, 30 Jan 2023 14:32:28 +0100 Subject: [PATCH 01/26] funktion printlabyrinth erstellt --- src/c/labyrinth.c | 20 ++++++++++++++++++++ src/c/labyrinth.h | 10 ++++++++++ test/c/test_labyrinth.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 src/c/labyrinth.c create mode 100644 src/c/labyrinth.h create mode 100644 test/c/test_labyrinth.c diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c new file mode 100644 index 0000000..dc8b99c --- /dev/null +++ b/src/c/labyrinth.c @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include +#include "labyrinth.h" + + + +int printlabyrinth(lab laby, int hoehe, int breite){ + + for(int i = 0; i < hoehe; i++){ + for(int j = 0; j < breite; j++){ + printf("%c ", laby[i][j]); + } + printf("\n"); + } + +return 0; +} \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h new file mode 100644 index 0000000..bda98ae --- /dev/null +++ b/src/c/labyrinth.h @@ -0,0 +1,10 @@ +#ifndef LABYRINTH_H +#define LABYRINTH_H + +#define MAXZEILEN 5 +#define MAXSPALTEN 5 + +typedef char lab[MAXZEILEN][MAXSPALTEN]; +int printlabyrinth(lab laby, int hoehe, int breite); + +#endif \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c new file mode 100644 index 0000000..5f3aa56 --- /dev/null +++ b/test/c/test_labyrinth.c @@ -0,0 +1,36 @@ +#ifdef TEST +#include "unity.h" +//in example.h wird die Funktion deklariert +#include "labyrinth.h" + +//Vor- bzw. Nachbereitung +void setUp(void) +{ +} + +void tearDown(void) +{ +} + + +void test_runExampleTest(void) +{ + + int result; + int input = 1; + int hoehe = 3; + int breite = 3; + lab laby = { + {'1', '2', '3'}, + {'4', '5', '6'}, + {'7', '8', '9'}, + }; + + + result = printlabyrinth(laby, hoehe, breite); + + + TEST_ASSERT_EQUAL_INT(0, result); +} + +#endif // TEST \ No newline at end of file From 8014dae17d6265e2c00515d85f405ff127f449f9 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Mon, 30 Jan 2023 14:44:38 +0100 Subject: [PATCH 02/26] Funktion wegsuchen erstellt --- src/c/labyrinth.c | 6 ++++++ src/c/labyrinth.h | 1 + test/c/test_labyrinth.c | 21 ++++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index dc8b99c..b1b98e2 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -17,4 +17,10 @@ int printlabyrinth(lab laby, int hoehe, int breite){ } return 0; +} + +int wegsuchen(lab laby, int startx, int starty, int zielx, int ziely){ + + + return 0; } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index bda98ae..35e6aae 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -6,5 +6,6 @@ typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); +int wegsuchen(lab laby, int startx, int starty, int zielx, int ziely); #endif \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 5f3aa56..fb7f7ea 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -24,7 +24,7 @@ void test_runExampleTest(void) {'1', '2', '3'}, {'4', '5', '6'}, {'7', '8', '9'}, - }; + }; result = printlabyrinth(laby, hoehe, breite); @@ -33,4 +33,23 @@ void test_runExampleTest(void) TEST_ASSERT_EQUAL_INT(0, result); } + +void test_LabyrinthAmZiel(void){ + + int result; + int input = 1; + int hoehe = 3; + int breite = 3; + lab laby = { + {'1', '2', '3'}, + {'4', '5', '6'}, + {'7', '8', '9'}, + }; + + result = wegsuchen(laby, 0, 0, 0, 0); + TEST_ASSERT_EQUAL_INT(0, result); + + +} + #endif // TEST \ No newline at end of file From ecb3df3e5d879217ac8c9954d26cd57cf19e7ec0 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Mon, 30 Jan 2023 14:50:55 +0100 Subject: [PATCH 03/26] =?UTF-8?q?If=20f=C3=BCr=20noch=20nicht=20am=20Ziel?= =?UTF-8?q?=20erstellt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 9 +++++++-- test/c/test_labyrinth.c | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index b1b98e2..e177437 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -21,6 +21,11 @@ return 0; int wegsuchen(lab laby, int startx, int starty, int zielx, int ziely){ - - return 0; + if(startx == zielx && starty == ziely){ + return 0; + } + else{ + return -1; + } + } \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index fb7f7ea..0f05551 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -50,6 +50,24 @@ void test_LabyrinthAmZiel(void){ TEST_ASSERT_EQUAL_INT(0, result); +} + +void test_LabyrinthAmZiel2(void){ + + int result; + int input = 1; + int hoehe = 3; + int breite = 3; + lab laby = { + {'1', '2', '3'}, + {'4', '5', '6'}, + {'7', '8', '9'}, + }; + + result = wegsuchen(laby, 1, 1, 0, 0); + TEST_ASSERT_EQUAL_INT(-1, result); + + } #endif // TEST \ No newline at end of file From a77663b73d958600caaebecee410f7c44bd60118 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 10:09:40 +0100 Subject: [PATCH 04/26] =?UTF-8?q?refactoring:=20variablennamen=20ge=C3=A4n?= =?UTF-8?q?dert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 4 ++-- src/c/labyrinth.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index e177437..cb15a6b 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -19,9 +19,9 @@ int printlabyrinth(lab laby, int hoehe, int breite){ return 0; } -int wegsuchen(lab laby, int startx, int starty, int zielx, int ziely){ +int wegsuchen(lab laby, int y, int x, int ziely, int zielx){ - if(startx == zielx && starty == ziely){ + if(x == zielx && y == ziely){ return 0; } else{ diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 35e6aae..3d1ee01 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -6,6 +6,6 @@ typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); -int wegsuchen(lab laby, int startx, int starty, int zielx, int ziely); +int wegsuchen(lab laby, int y, int x, int ziely, int zielx); #endif \ No newline at end of file From 4e0f06b2737d9898fef2957873fb6cb439301d6d Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 10:24:04 +0100 Subject: [PATCH 05/26] Gegangenen weg makiert --- src/c/labyrinth.c | 3 +++ test/c/test_labyrinth.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index cb15a6b..a5feb45 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -15,12 +15,15 @@ int printlabyrinth(lab laby, int hoehe, int breite){ } printf("\n"); } + printf("\n"); return 0; } int wegsuchen(lab laby, int y, int x, int ziely, int zielx){ + laby[y][x] = 'X'; + if(x == zielx && y == ziely){ return 0; } diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 0f05551..6f93168 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -68,6 +68,27 @@ void test_LabyrinthAmZiel2(void){ TEST_ASSERT_EQUAL_INT(-1, result); +} + +void test_LabyrinthMarkiert(void){ + + char result; + int input = 1; + int hoehe = 3; + int breite = 3; + lab laby = { + {'0', '1', '1'}, + {'1', '1', '1'}, + {'1', '1', '1'}, + }; + + + wegsuchen(laby, 0, 0, 0, 0); + result = laby[0][0]; + printlabyrinth(laby, hoehe, breite); + TEST_ASSERT_EQUAL_CHAR('X', result); + + } #endif // TEST \ No newline at end of file From 27d170b01f6f8626a5d5704babd9f1f1fad5bfeb Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 10:53:08 +0100 Subject: [PATCH 06/26] =?UTF-8?q?return-typ=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 7 +++---- src/c/labyrinth.h | 4 +++- test/c/test_labyrinth.c | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index a5feb45..6ca56f7 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -20,15 +20,14 @@ int printlabyrinth(lab laby, int hoehe, int breite){ return 0; } -int wegsuchen(lab laby, int y, int x, int ziely, int zielx){ +void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ laby[y][x] = 'X'; if(x == zielx && y == ziely){ - return 0; + *done = true; } else{ - return -1; + *done = false; } - } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 3d1ee01..146fffb 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -1,11 +1,13 @@ #ifndef LABYRINTH_H #define LABYRINTH_H +#include + #define MAXZEILEN 5 #define MAXSPALTEN 5 typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); -int wegsuchen(lab laby, int y, int x, int ziely, int zielx); +void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx); #endif \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 6f93168..a399512 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -2,6 +2,7 @@ #include "unity.h" //in example.h wird die Funktion deklariert #include "labyrinth.h" +#include //Vor- bzw. Nachbereitung void setUp(void) @@ -14,8 +15,7 @@ void tearDown(void) void test_runExampleTest(void) -{ - +{ int result; int input = 1; int hoehe = 3; @@ -36,7 +36,7 @@ void test_runExampleTest(void) void test_LabyrinthAmZiel(void){ - int result; + bool result; int input = 1; int hoehe = 3; int breite = 3; @@ -46,15 +46,15 @@ void test_LabyrinthAmZiel(void){ {'7', '8', '9'}, }; - result = wegsuchen(laby, 0, 0, 0, 0); - TEST_ASSERT_EQUAL_INT(0, result); + wegsuchen(laby, &result, 0, 0, 0, 0); + TEST_ASSERT_EQUAL_INT(1, result); } void test_LabyrinthAmZiel2(void){ - int result; + bool result; int input = 1; int hoehe = 3; int breite = 3; @@ -64,8 +64,8 @@ void test_LabyrinthAmZiel2(void){ {'7', '8', '9'}, }; - result = wegsuchen(laby, 1, 1, 0, 0); - TEST_ASSERT_EQUAL_INT(-1, result); + wegsuchen(laby, &result, 1, 1, 0, 0); + TEST_ASSERT_EQUAL_INT(0, result); } @@ -73,6 +73,7 @@ void test_LabyrinthAmZiel2(void){ void test_LabyrinthMarkiert(void){ char result; + bool du; int input = 1; int hoehe = 3; int breite = 3; @@ -83,7 +84,7 @@ void test_LabyrinthMarkiert(void){ }; - wegsuchen(laby, 0, 0, 0, 0); + wegsuchen(laby, &du, 0, 0, 0, 0); result = laby[0][0]; printlabyrinth(laby, hoehe, breite); TEST_ASSERT_EQUAL_CHAR('X', result); From 22a2f5c22153ca73780de72c2c06a6efef4c5552 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 10:56:20 +0100 Subject: [PATCH 07/26] refactoring: funktionsnamen geaendert --- test/c/test_labyrinth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index a399512..ee0a2bd 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -34,7 +34,7 @@ void test_runExampleTest(void) } -void test_LabyrinthAmZiel(void){ +void test_LabyrinthAmZielAngekommen(void){ bool result; int input = 1; @@ -52,7 +52,7 @@ void test_LabyrinthAmZiel(void){ } -void test_LabyrinthAmZiel2(void){ +void test_LabyrinthAmZielNichtAngekommen(void){ bool result; int input = 1; From 84cbf04cf15daff21e41c3b75dc945c42c56d172 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 11:21:15 +0100 Subject: [PATCH 08/26] =?UTF-8?q?if=20anweisung=20nach=20unten=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 4 +++- test/c/test_labyrinth.c | 27 +++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 6ca56f7..0570655 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -28,6 +28,8 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ *done = true; } else{ - *done = false; + if (!*done && y + 1 <= ziely && laby[y+1][x] == '0'){ + wegsuchen(laby, done, y + 1, x, ziely, zielx); + } } } \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index ee0a2bd..1fb675b 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -54,14 +54,14 @@ void test_LabyrinthAmZielAngekommen(void){ void test_LabyrinthAmZielNichtAngekommen(void){ - bool result; + bool result = 0; int input = 1; int hoehe = 3; int breite = 3; lab laby = { - {'1', '2', '3'}, - {'4', '5', '6'}, - {'7', '8', '9'}, + {'0', '1', '1'}, + {'1', '0', '1'}, + {'1', '1', '1'}, }; wegsuchen(laby, &result, 1, 1, 0, 0); @@ -90,6 +90,25 @@ void test_LabyrinthMarkiert(void){ TEST_ASSERT_EQUAL_CHAR('X', result); +} + +void test_LabyrinthUnten(void){ + + bool result; + int input = 1; + int hoehe = 3; + int breite = 3; + lab laby = { + {'0', '1', '1'}, + {'0', '1', '1'}, + {'0', '1', '1'}, + }; + + wegsuchen(laby, &result, 0, 0, 2, 0); + printlabyrinth(laby, hoehe, breite); + TEST_ASSERT_EQUAL_INT(1, result); + + } #endif // TEST \ No newline at end of file From df3ed5c1b27ce3091d9887f75347d4e2c0bdc92d Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 11:26:27 +0100 Subject: [PATCH 09/26] =?UTF-8?q?if=20anweisung=20nach=20rechts=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 3 +++ test/c/test_labyrinth.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 0570655..c4cefe3 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -31,5 +31,8 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ if (!*done && y + 1 <= ziely && laby[y+1][x] == '0'){ wegsuchen(laby, done, y + 1, x, ziely, zielx); } + if (!*done && x + 1 <= zielx && laby[y][x+1] == '0'){ + wegsuchen(laby, done, y, x + 1, ziely, zielx); + } } } \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 1fb675b..9b9448c 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -109,6 +109,25 @@ void test_LabyrinthUnten(void){ TEST_ASSERT_EQUAL_INT(1, result); +} + +void test_LabyrinthRechts(void){ + + bool result; + int input = 1; + int hoehe = 3; + int breite = 3; + lab laby = { + {'0', '0', '0'}, + {'1', '1', '1'}, + {'1', '1', '1'}, + }; + + wegsuchen(laby, &result, 0, 0, 0, 2); + printlabyrinth(laby, hoehe, breite); + TEST_ASSERT_EQUAL_INT(1, result); + + } #endif // TEST \ No newline at end of file From 07524ab01cf1f9ccd5b3e3ea228bb388e2cbf5e4 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 11:35:22 +0100 Subject: [PATCH 10/26] =?UTF-8?q?if=20Anweisung=20nach=20oben=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 3 +++ test/c/test_labyrinth.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index c4cefe3..410dce2 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -34,5 +34,8 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ if (!*done && x + 1 <= zielx && laby[y][x+1] == '0'){ wegsuchen(laby, done, y, x + 1, ziely, zielx); } + if (!*done && y - 1 >= 0 && laby[y-1][x] == '0'){ // oben + wegsuchen(laby, done, y - 1, x, ziely, zielx); + } } } \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 9b9448c..f2d1e80 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -126,8 +126,26 @@ void test_LabyrinthRechts(void){ wegsuchen(laby, &result, 0, 0, 0, 2); printlabyrinth(laby, hoehe, breite); TEST_ASSERT_EQUAL_INT(1, result); +} + +void test_LabyrinthOben(void){ + bool result; + int input = 1; + int hoehe = 5; + int breite = 5; + lab laby = { + {'0', '1', '0', '0', '0'}, + {'0', '1', '0', '1', '0'}, + {'0', '1', '0', '1', '0'}, + {'0', '1', '0', '1', '0'}, + {'0', '0', '0', '1', '0'}, + }; + + wegsuchen(laby, &result, 0, 0, 4, 4); + printlabyrinth(laby, hoehe, breite); + TEST_ASSERT_EQUAL_INT(1, result); } #endif // TEST \ No newline at end of file From c485a3c87bc6d7a8ab0b3470160913d4edff25bf Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 11:41:30 +0100 Subject: [PATCH 11/26] =?UTF-8?q?if=20Anweisung=20nach=20links=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 4 ++++ src/c/labyrinth.h | 4 ++-- test/c/test_labyrinth.c | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 410dce2..f791a7f 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -37,5 +37,9 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ if (!*done && y - 1 >= 0 && laby[y-1][x] == '0'){ // oben wegsuchen(laby, done, y - 1, x, ziely, zielx); } + if (!*done && x - 1 >= 0 && laby[y][x-1] == '0'){ // links + wegsuchen(laby, done, y, x - 1, ziely, zielx); + } + } } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 146fffb..3d71f1e 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -3,8 +3,8 @@ #include -#define MAXZEILEN 5 -#define MAXSPALTEN 5 +#define MAXZEILEN 10 +#define MAXSPALTEN 10 typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index f2d1e80..369501e 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -148,4 +148,24 @@ void test_LabyrinthOben(void){ TEST_ASSERT_EQUAL_INT(1, result); } + +void test_LabyrinthLinks(void){ + + bool result; + int input = 1; + int hoehe = 5; + int breite = 6; + lab laby = { + {'0', '1', '0', '0', '0', '0'}, + {'0', '1', '0', '1', '1', '0'}, + {'0', '1', '0', '0', '1', '0'}, + {'0', '1', '1', '0', '1', '0'}, + {'0', '0', '0', '0', '1', '0'}, + }; + + wegsuchen(laby, &result, 0, 0, 4, 5); + printlabyrinth(laby, hoehe, breite); + TEST_ASSERT_EQUAL_INT(1, result); +} + #endif // TEST \ No newline at end of file From 4e567d5131a52ebda77dea02b9a947f87ceec362 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 11:48:07 +0100 Subject: [PATCH 12/26] =?UTF-8?q?if=20Anweisung=20wenn=20nicht=20loesbar?= =?UTF-8?q?=20inugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index f791a7f..ef4b942 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -40,6 +40,9 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ if (!*done && x - 1 >= 0 && laby[y][x-1] == '0'){ // links wegsuchen(laby, done, y, x - 1, ziely, zielx); } + if (!*done){ + laby[y][x] = '0'; + } } } \ No newline at end of file From 90f80c32b1e3c33ad262ac5a4e4381d14018f187 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 12:54:12 +0100 Subject: [PATCH 13/26] =?UTF-8?q?testfall=20f=C3=BCr=20verzweigungen=20hin?= =?UTF-8?q?zugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/c/test_labyrinth.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 369501e..f19c08f 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -168,4 +168,23 @@ void test_LabyrinthLinks(void){ TEST_ASSERT_EQUAL_INT(1, result); } +void test_LabyrinthVerzweigung(void){ + + bool result; + int input = 1; + int hoehe = 5; + int breite = 6; + lab laby = { + {'0', '1', '0', '0', '0', '0'}, + {'0', '1', '0', '1', '1', '0'}, + {'0', '0', '0', '0', '1', '0'}, + {'0', '1', '1', '0', '1', '0'}, + {'0', '1', '0', '0', '1', '0'}, + }; + + wegsuchen(laby, &result, 0, 0, 4, 5); + printlabyrinth(laby, hoehe, breite); + TEST_ASSERT_EQUAL_INT(1, result); +} + #endif // TEST \ No newline at end of file From a02f1e1692103a787af909e9e11e1df4ae15a4e8 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 19:31:00 +0100 Subject: [PATCH 14/26] refactoring: character durch WEG ersetzt --- src/c/labyrinth.c | 13 +++++++------ src/c/labyrinth.h | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index ef4b942..7a7683b 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -20,29 +20,30 @@ int printlabyrinth(lab laby, int hoehe, int breite){ return 0; } + void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ laby[y][x] = 'X'; + if(x == zielx && y == ziely){ *done = true; } else{ - if (!*done && y + 1 <= ziely && laby[y+1][x] == '0'){ + if (!*done && y + 1 <= ziely && laby[y+1][x] == WEG){ wegsuchen(laby, done, y + 1, x, ziely, zielx); } - if (!*done && x + 1 <= zielx && laby[y][x+1] == '0'){ + if (!*done && x + 1 <= zielx && laby[y][x+1] == WEG){ wegsuchen(laby, done, y, x + 1, ziely, zielx); } - if (!*done && y - 1 >= 0 && laby[y-1][x] == '0'){ // oben + if (!*done && y - 1 >= 0 && laby[y-1][x] == WEG){ // oben wegsuchen(laby, done, y - 1, x, ziely, zielx); } - if (!*done && x - 1 >= 0 && laby[y][x-1] == '0'){ // links + if (!*done && x - 1 >= 0 && laby[y][x-1] == WEG){ // links wegsuchen(laby, done, y, x - 1, ziely, zielx); } if (!*done){ - laby[y][x] = '0'; + laby[y][x] = WEG; } - } } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 3d71f1e..1ef7b8c 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -5,6 +5,7 @@ #define MAXZEILEN 10 #define MAXSPALTEN 10 +#define WEG '0' typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); From c7f2d823dde1d7a2265cb1f1e15cc915c97717c2 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 20:21:58 +0100 Subject: [PATCH 15/26] refactoring: statt 'X', MARKIERT eingesetzt --- src/c/labyrinth.c | 2 +- src/c/labyrinth.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 7a7683b..43c10c6 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -23,7 +23,7 @@ return 0; void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ - laby[y][x] = 'X'; + laby[y][x] = MARKIERT; if(x == zielx && y == ziely){ diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 1ef7b8c..e35fe8a 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -6,6 +6,7 @@ #define MAXZEILEN 10 #define MAXSPALTEN 10 #define WEG '0' +#define MARKIERT 'X' typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); From d0828ccdbeb5293e615deeb793a01fba49575c0f Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 11:44:35 +0100 Subject: [PATCH 16/26] =?UTF-8?q?Funktion=20labyrinthschritte=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 21 ++++++++++++++++++++- src/c/labyrinth.h | 2 +- test/c/test_labyrinth.c | 27 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 43c10c6..8d67d40 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -4,6 +4,7 @@ #include #include #include "labyrinth.h" +#include "userinput.h" @@ -16,7 +17,9 @@ int printlabyrinth(lab laby, int hoehe, int breite){ printf("\n"); } printf("\n"); - + printf("Wie viele Schritte brauchen Sie bis zum Ziel?\n"); + printf("\n"); + return 0; } @@ -46,4 +49,20 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ laby[y][x] = WEG; } } +} + +int labyrinthschritte(lab laby, int hoehe, int breite, int schritte){ + + + + for(int i = 0; i < hoehe; i++){ + for(int j = 0; j < breite; j++){ + printf("%c ", laby[i][j]); + } + printf("\n"); + } + printf("\n"); + + + } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index e35fe8a..6da7a5d 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -11,5 +11,5 @@ typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx); - +int labyrinthschritte(lab laby, int hoehe, int breite, int schritte); #endif \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index f19c08f..6e774e5 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -3,6 +3,8 @@ //in example.h wird die Funktion deklariert #include "labyrinth.h" #include +#include "userinput.h" +#include "mock_userinput.h" //Vor- bzw. Nachbereitung void setUp(void) @@ -174,6 +176,7 @@ void test_LabyrinthVerzweigung(void){ int input = 1; int hoehe = 5; int breite = 6; + lab laby = { {'0', '1', '0', '0', '0', '0'}, {'0', '1', '0', '1', '1', '0'}, @@ -182,9 +185,33 @@ void test_LabyrinthVerzweigung(void){ {'0', '1', '0', '0', '1', '0'}, }; + wegsuchen(laby, &result, 0, 0, 4, 5); printlabyrinth(laby, hoehe, breite); TEST_ASSERT_EQUAL_INT(1, result); } + +void test_LabyrinthSchritte(void){ + + bool result; + int input = 1; + int hoehe = 5; + int breite = 6; + int schritte = 14; + lab laby = { + {'0', '1', '0', '0', '0', '0'}, + {'0', '1', '0', '1', '1', '0'}, + {'0', '0', '0', '0', '1', '0'}, + {'0', '1', '1', '0', '1', '0'}, + {'0', '1', '0', '0', '1', '0'}, + }; + + printlabyrinth(laby, hoehe, breite); //hier in die funktion die print frage machen + wegsuchen(laby, &result, 0, 0, 4, 5); + labyrinthschritte(laby, hoehe, breite, schritte); //die geliche funktion nur mit dem if vergleich und userinput + TEST_ASSERT_EQUAL_INT(1, result); + +} + #endif // TEST \ No newline at end of file From 843946a5c1fd77339a95ca412beec62e33b0bc00 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 11:49:30 +0100 Subject: [PATCH 17/26] =?UTF-8?q?refactoring:=20R=C3=BCckgabetyp=20der=20F?= =?UTF-8?q?unktion=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 4 +--- src/c/labyrinth.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 8d67d40..9e54bf3 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -51,7 +51,7 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ } } -int labyrinthschritte(lab laby, int hoehe, int breite, int schritte){ +void labyrinthschritte(lab laby, int hoehe, int breite, int schritte){ @@ -63,6 +63,4 @@ int labyrinthschritte(lab laby, int hoehe, int breite, int schritte){ } printf("\n"); - - } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 6da7a5d..71c1338 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -11,5 +11,5 @@ typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx); -int labyrinthschritte(lab laby, int hoehe, int breite, int schritte); +void labyrinthschritte(lab laby, int hoehe, int breite, int schritte); #endif \ No newline at end of file From f74b350ebdd5e1715339dbb8acb92b55db251a0c Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 11:51:03 +0100 Subject: [PATCH 18/26] =?UTF-8?q?if=20Anweisung=20f=C3=BCr=20richtige=20an?= =?UTF-8?q?twort=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 9e54bf3..2c40653 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -53,7 +53,7 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte){ - + int antwort = 0; for(int i = 0; i < hoehe; i++){ for(int j = 0; j < breite; j++){ @@ -63,4 +63,11 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte){ } printf("\n"); + antwort = 14; + + if(antwort == schritte){ + printf("Richtig, Sie brauchen %d Schritte.\n", schritte); + } + + } \ No newline at end of file From 2120ad603f455b59e90d1b405f7924bf361bfe3c Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 11:58:02 +0100 Subject: [PATCH 19/26] =?UTF-8?q?refactoring:=20Ausgabe=20der=20Funktion?= =?UTF-8?q?=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 2c40653..ab9038e 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -55,19 +55,21 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte){ int antwort = 0; - for(int i = 0; i < hoehe; i++){ - for(int j = 0; j < breite; j++){ - printf("%c ", laby[i][j]); - } - printf("\n"); - } - printf("\n"); - antwort = 14; if(antwort == schritte){ printf("Richtig, Sie brauchen %d Schritte.\n", schritte); + + for(int i = 0; i < hoehe; i++){ + for(int j = 0; j < breite; j++){ + printf("%c ", laby[i][j]); + } + printf("\n"); + } + printf("\n"); } + + } \ No newline at end of file From 4ea6bdf485b487e940116e1573077c44d3ada419 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 12:08:49 +0100 Subject: [PATCH 20/26] =?UTF-8?q?else=20f=C3=BCr=20falsche=20antowort=20hi?= =?UTF-8?q?nzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 15 ++++++++++----- src/c/labyrinth.h | 2 +- test/c/test_labyrinth.c | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index ab9038e..d0dc35b 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -51,11 +51,12 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ } } -void labyrinthschritte(lab laby, int hoehe, int breite, int schritte){ +void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuche){ int antwort = 0; + - antwort = 14; + antwort = 5; if(antwort == schritte){ printf("Richtig, Sie brauchen %d Schritte.\n", schritte); @@ -68,8 +69,12 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte){ } printf("\n"); } - - + else{ + if(versuche != 3){ + printf("Ihre Antwort ist falsch. Versuchen Sie es erneut.\n"); + versuche = versuche + 1; + labyrinthschritte(laby, hoehe, breite, schritte, versuche); //if schleife für 3 versuche + } - + } } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 71c1338..e40ccf1 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -11,5 +11,5 @@ typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx); -void labyrinthschritte(lab laby, int hoehe, int breite, int schritte); +void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuche); #endif \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 6e774e5..05a78e9 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -199,6 +199,7 @@ void test_LabyrinthSchritte(void){ int hoehe = 5; int breite = 6; int schritte = 14; + int versuche = 0; lab laby = { {'0', '1', '0', '0', '0', '0'}, {'0', '1', '0', '1', '1', '0'}, @@ -209,7 +210,7 @@ void test_LabyrinthSchritte(void){ printlabyrinth(laby, hoehe, breite); //hier in die funktion die print frage machen wegsuchen(laby, &result, 0, 0, 4, 5); - labyrinthschritte(laby, hoehe, breite, schritte); //die geliche funktion nur mit dem if vergleich und userinput + labyrinthschritte(laby, hoehe, breite, schritte, versuche); //die geliche funktion nur mit dem if vergleich und userinput TEST_ASSERT_EQUAL_INT(1, result); } From c2ea22f2d0d1f25aa3d3038b79788b651d7dcd04 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 12:09:33 +0100 Subject: [PATCH 21/26] =?UTF-8?q?else=20mit=20ausgabe=20verloren=20hinzuge?= =?UTF-8?q?f=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index d0dc35b..2e64e94 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -75,6 +75,8 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuc versuche = versuche + 1; labyrinthschritte(laby, hoehe, breite, schritte, versuche); //if schleife für 3 versuche } - + else{ + printf("Verloren\n"); + } } } \ No newline at end of file From d57c095e3db7ecd6652eaf6e052b928efbfdb2cd Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 12:19:48 +0100 Subject: [PATCH 22/26] =?UTF-8?q?refactoring:=20ausgabe=20und=20variablenn?= =?UTF-8?q?amen=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 8 ++++---- test/c/test_labyrinth.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 2e64e94..b9d4c66 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -17,7 +17,7 @@ int printlabyrinth(lab laby, int hoehe, int breite){ printf("\n"); } printf("\n"); - printf("Wie viele Schritte brauchen Sie bis zum Ziel?\n"); + printf("How many steps do you need to reach your goal?\n"); printf("\n"); return 0; @@ -59,7 +59,7 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuc antwort = 5; if(antwort == schritte){ - printf("Richtig, Sie brauchen %d Schritte.\n", schritte); + printf("Correct you need %d steps.\n", schritte); for(int i = 0; i < hoehe; i++){ for(int j = 0; j < breite; j++){ @@ -71,12 +71,12 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuc } else{ if(versuche != 3){ - printf("Ihre Antwort ist falsch. Versuchen Sie es erneut.\n"); + printf("Your answer is wrong. Try again.\n"); versuche = versuche + 1; labyrinthschritte(laby, hoehe, breite, schritte, versuche); //if schleife für 3 versuche } else{ - printf("Verloren\n"); + printf("You lost.\n"); } } } \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 05a78e9..4f20e3a 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -75,7 +75,7 @@ void test_LabyrinthAmZielNichtAngekommen(void){ void test_LabyrinthMarkiert(void){ char result; - bool du; + bool fertig; int input = 1; int hoehe = 3; int breite = 3; @@ -86,7 +86,7 @@ void test_LabyrinthMarkiert(void){ }; - wegsuchen(laby, &du, 0, 0, 0, 0); + wegsuchen(laby, &fertig, 0, 0, 0, 0); result = laby[0][0]; printlabyrinth(laby, hoehe, breite); TEST_ASSERT_EQUAL_CHAR('X', result); From 2bbaff4c4e62fc54b4df98ea4eaabde068faf8d8 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 12:27:52 +0100 Subject: [PATCH 23/26] =?UTF-8?q?userinput=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 2 +- test/c/test_labyrinth.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index b9d4c66..7d4fb9b 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -56,7 +56,7 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuc int antwort = 0; - antwort = 5; + antwort = userInput(); if(antwort == schritte){ printf("Correct you need %d steps.\n", schritte); diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 4f20e3a..690272e 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -210,6 +210,9 @@ void test_LabyrinthSchritte(void){ printlabyrinth(laby, hoehe, breite); //hier in die funktion die print frage machen wegsuchen(laby, &result, 0, 0, 4, 5); + + userInput_ExpectAndReturn(14); + labyrinthschritte(laby, hoehe, breite, schritte, versuche); //die geliche funktion nur mit dem if vergleich und userinput TEST_ASSERT_EQUAL_INT(1, result); From dd8ee0b8be1079bf27c7e91152e7161babb73024 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 12:33:56 +0100 Subject: [PATCH 24/26] =?UTF-8?q?Testfall=20f=C3=BCr=20verloren=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/c/test_labyrinth.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 690272e..fe10bbc 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -218,4 +218,33 @@ void test_LabyrinthSchritte(void){ } +void test_LabyrinthSchritteVerloren(void){ + + bool result; + int input = 1; + int hoehe = 5; + int breite = 6; + int schritte = 14; + int versuche = 0; + lab laby = { + {'0', '1', '0', '0', '0', '0'}, + {'0', '1', '0', '1', '1', '0'}, + {'0', '0', '0', '0', '1', '0'}, + {'0', '1', '1', '0', '1', '0'}, + {'0', '1', '0', '0', '1', '0'}, + }; + + printlabyrinth(laby, hoehe, breite); //hier in die funktion die print frage machen + wegsuchen(laby, &result, 0, 0, 4, 5); + + userInput_ExpectAndReturn(5); + userInput_ExpectAndReturn(8); + userInput_ExpectAndReturn(10); + userInput_ExpectAndReturn(9); + + labyrinthschritte(laby, hoehe, breite, schritte, versuche); //die geliche funktion nur mit dem if vergleich und userinput + TEST_ASSERT_EQUAL_INT(1, result); + +} + #endif // TEST \ No newline at end of file From 3ca77efa51fe4dc63a5594eefae7c7debf704128 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 12:35:34 +0100 Subject: [PATCH 25/26] =?UTF-8?q?Testfall=20beim=20letzten=20versuch=20gew?= =?UTF-8?q?onnen=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/c/test_labyrinth.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index fe10bbc..2a110b2 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -247,4 +247,33 @@ void test_LabyrinthSchritteVerloren(void){ } +void test_LabyrinthSchritteBeiDreiGewonnen(void){ + + bool result; + int input = 1; + int hoehe = 5; + int breite = 6; + int schritte = 14; + int versuche = 0; + lab laby = { + {'0', '1', '0', '0', '0', '0'}, + {'0', '1', '0', '1', '1', '0'}, + {'0', '0', '0', '0', '1', '0'}, + {'0', '1', '1', '0', '1', '0'}, + {'0', '1', '0', '0', '1', '0'}, + }; + + printlabyrinth(laby, hoehe, breite); //hier in die funktion die print frage machen + wegsuchen(laby, &result, 0, 0, 4, 5); + + userInput_ExpectAndReturn(5); + userInput_ExpectAndReturn(8); + userInput_ExpectAndReturn(10); + userInput_ExpectAndReturn(14); + + labyrinthschritte(laby, hoehe, breite, schritte, versuche); //die geliche funktion nur mit dem if vergleich und userinput + TEST_ASSERT_EQUAL_INT(1, result); + +} + #endif // TEST \ No newline at end of file From 2cf6c7a5fa5eb9e7a8df46039cfeb6b037d438bb Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 12:53:32 +0100 Subject: [PATCH 26/26] =?UTF-8?q?Funktion=20labyrinthauswahl=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 25 ++++++++++++++++++++++++- src/c/labyrinth.h | 1 + test/c/test_labyrinth.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 7d4fb9b..10998d1 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -19,7 +19,6 @@ int printlabyrinth(lab laby, int hoehe, int breite){ printf("\n"); printf("How many steps do you need to reach your goal?\n"); printf("\n"); - return 0; } @@ -79,4 +78,28 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuc printf("You lost.\n"); } } +} + +void labyrinthauswahl(int auswahl){ + + printf("Bitte wählen Sie ein Labyrinth aus\n"); + + switch (auswahl){ + case 1: + lab laby = { + {'0', '1', '0', '0', '0', '0'}, + {'0', '1', '0', '1', '1', '0'}, + {'0', '0', '0', '0', '1', '0'}, + {'0', '1', '1', '0', '1', '0'}, + {'0', '1', '0', '0', '1', '0'}, + }; + int hoehe = 5; + int breite = 6; + printlabyrinth(laby, hoehe, breite); + break; + + default: + break; + } + } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index e40ccf1..0147da5 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -12,4 +12,5 @@ typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx); void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuche); +void labyrinthauswahl(int auswahl); #endif \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 2a110b2..cf05752 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -276,4 +276,38 @@ void test_LabyrinthSchritteBeiDreiGewonnen(void){ } +void test_LabyrinthAuswahl(void){ + + bool result; + int input = 1; + int hoehe = 5; + int breite = 6; + int schritte = 14; + int versuche = 0; + int auswahl = 1; + + + + lab laby = { + {'0', '1', '0', '0', '0', '0'}, + {'0', '1', '0', '1', '1', '0'}, + {'0', '0', '0', '0', '1', '0'}, + {'0', '1', '1', '0', '1', '0'}, + {'0', '1', '0', '0', '1', '0'}, + }; + + labyrinthauswahl(auswahl); + //printlabyrinth(laby, hoehe, breite); //hier in die funktion die print frage machen + wegsuchen(laby, &result, 0, 0, 4, 5); + + userInput_ExpectAndReturn(5); + userInput_ExpectAndReturn(8); + userInput_ExpectAndReturn(10); + userInput_ExpectAndReturn(14); + + labyrinthschritte(laby, hoehe, breite, schritte, versuche); //die geliche funktion nur mit dem if vergleich und userinput + TEST_ASSERT_EQUAL_INT(1, result); + +} + #endif // TEST \ No newline at end of file