From ff173f7340cf1bf213b0e3ac9c870f7ea27b4950 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 15:26:45 +0100 Subject: [PATCH 1/5] =?UTF-8?q?weiteres=20labyrinzh=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 15 +++++++++++++++ test/c/test_labyrinth.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 10998d1..d2996ea 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -97,6 +97,21 @@ void labyrinthauswahl(int auswahl){ int breite = 6; printlabyrinth(laby, hoehe, breite); break; + case 2: + lab laby2 = { + {'0', '0', '0', '0', '1', '0', '1', '1', '0'}, + {'1', '0', '1', '0', '0', '1', '1', '1', '0'}, + {'1', '0', '1', '1', '0', '0', '1', '1', '0'}, + {'0', '0', '0', '1', '1', '0', '1', '0', '1'}, + {'0', '1', '0', '1', '0', '0', '1', '0', '1'}, + {'0', '1', '0', '1', '0', '1', '0', '0', '0'}, + {'0', '1', '0', '1', '0', '0', '0', '1', '0'}, + + }; + hoehe = 7; + breite = 9; + printlabyrinth(laby2, hoehe, breite); + break; default: break; diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index cf05752..8a9cf5d 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -310,4 +310,41 @@ void test_LabyrinthAuswahl(void){ } + +void test_LabyrinthAuswahl2(void){ + + bool result; + int input = 1; + int hoehe = 7; + int breite = 9; + int schritte = 19; + int versuche = 0; + int auswahl = 2; + + + + lab laby = { + {'0', '0', '0', '0', '1', '0', '1', '1', '0'}, + {'1', '0', '1', '0', '0', '1', '1', '1', '0'}, + {'1', '0', '1', '1', '0', '0', '1', '1', '0'}, + {'0', '0', '0', '1', '1', '0', '1', '0', '1'}, + {'0', '1', '0', '1', '0', '0', '1', '0', '1'}, + {'0', '1', '0', '1', '0', '1', '0', '0', '0'}, + {'0', '1', '0', '1', '0', '0', '0', '1', '0'}, + }; + + labyrinthauswahl(auswahl); + //printlabyrinth(laby, hoehe, breite); //hier in die funktion die print frage machen + wegsuchen(laby, &result, 0, 0, 6, 8); + + userInput_ExpectAndReturn(5); + userInput_ExpectAndReturn(8); + userInput_ExpectAndReturn(10); + userInput_ExpectAndReturn(schritte); + + labyrinthschritte(laby, hoehe, breite, schritte, versuche); //die gleiche funktion nur mit dem if vergleich und userinput + TEST_ASSERT_EQUAL_INT(1, result); + +} + #endif // TEST \ No newline at end of file From 8e695a48291dd15190432a8a81adbee596fb18ef Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 15:37:53 +0100 Subject: [PATCH 2/5] =?UTF-8?q?refactoring:=20labyrinthausgabe=20versch?= =?UTF-8?q?=C3=B6nert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index d2996ea..9dc72ba 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -11,8 +11,14 @@ 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]); + for(int j = 0; j < breite; j++){ + if(laby[i][j] == '1'){ + printf("■ "); + } + + else{ + printf("%c ", laby[i][j]); + } } printf("\n"); } From b7ab3e3bebe285f80bf7a96122b5d673f99dc9bd Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 15:39:19 +0100 Subject: [PATCH 3/5] =?UTF-8?q?else=20if=20hinzugef=C3=BCgt=20f=C3=BCr=20l?= =?UTF-8?q?abyrinth=20ausgabe?= 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 9dc72ba..91a0c9d 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -15,7 +15,9 @@ int printlabyrinth(lab laby, int hoehe, int breite){ if(laby[i][j] == '1'){ printf("■ "); } - + else if(laby[i][j] == WEG){ + printf(" "); + } else{ printf("%c ", laby[i][j]); } From d8939663cdc6375ac1f849861a5036a303410825 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 15:44:25 +0100 Subject: [PATCH 4/5] refactoring: labyrinth ausgabe verbessert --- src/c/labyrinth.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 91a0c9d..7cb860a 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -70,7 +70,15 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuc for(int i = 0; i < hoehe; i++){ for(int j = 0; j < breite; j++){ - printf("%c ", laby[i][j]); + if(laby[i][j] == '1'){ + printf("■ "); + } + else if(laby[i][j] == WEG){ + printf(" "); + } + else{ + printf("%c ", laby[i][j]); + } } printf("\n"); } @@ -90,7 +98,7 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuc void labyrinthauswahl(int auswahl){ - printf("Bitte wählen Sie ein Labyrinth aus\n"); + printf("Pleas choose a maze.\n"); switch (auswahl){ case 1: From fe0626233dc26a7ad859b357322512fee9ddd375 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Thu, 2 Feb 2023 15:47:58 +0100 Subject: [PATCH 5/5] =?UTF-8?q?refactoring:=20Mauer=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 7cb860a..6880654 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -70,7 +70,7 @@ void labyrinthschritte(lab laby, int hoehe, int breite, int schritte, int versuc for(int i = 0; i < hoehe; i++){ for(int j = 0; j < breite; j++){ - if(laby[i][j] == '1'){ + if(laby[i][j] == MAUER){ printf("■ "); } else if(laby[i][j] == WEG){ diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 0147da5..cd64f0a 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -7,6 +7,7 @@ #define MAXSPALTEN 10 #define WEG '0' #define MARKIERT 'X' +#define MAUER '1' typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite);