From a19c2caa67b1f266404c1f50797aa93641d7076e Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 15:21:56 +0100 Subject: [PATCH 01/17] =?UTF-8?q?Schreiben=20der=20Empfangsnachricht=20und?= =?UTF-8?q?=20Implementation=20des=20GameLoops=20+=20Ab=C3=A4nderung=20der?= =?UTF-8?q?=20Funktion=20zu=20void?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 26 ++++++++++++++++++++++--- src/main/c/Tim/SchereSteinPapier.h | 2 +- src/test/c/Tim/test_SchereSteinPapier.c | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 4d485f8..d71250a 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -2,8 +2,28 @@ #include -int schereSteinPapier() +void schereSteinPapier() { - printf("Test"); - return 1; + printf("\nHallo und Willkommen zu Schere-Stein-Papier!\n\nIn diesem Spiel spielst du gegen einen COM Schere-Stein-Papier!\n" + "Waehle, sobald dich die Konsole dazu auffordert, deine 'Waffe' aus, indem du die entsprechende Zahl eintippst.\n" + "Gibst du bei der Aufforderung 0 ein, gelangst du zurueck ins Hauptmenue!\n\n"); + while(1) + { + int com, user; + printf("Bitte treffe deine Wahl!\n" + "1: Schere \n2: Stein \n3: Papier\n0: Spiel verlassen\n"); + scanf("%d", &user); + if(user == 0) + { + break; + } + else if(user == 1 || user == 2 || user == 3) + { + //do something + } + else + { + printf("Deine eingegebene Wahl ist ungueltig\n"); + } + } } diff --git a/src/main/c/Tim/SchereSteinPapier.h b/src/main/c/Tim/SchereSteinPapier.h index 8b695c2..35c884b 100644 --- a/src/main/c/Tim/SchereSteinPapier.h +++ b/src/main/c/Tim/SchereSteinPapier.h @@ -1,6 +1,6 @@ #ifndef SCHERESTEINPAPIER_H #define SCHERESTEINPAPIER_H -int schereSteinPapier(); +void schereSteinPapier(); #endif diff --git a/src/test/c/Tim/test_SchereSteinPapier.c b/src/test/c/Tim/test_SchereSteinPapier.c index 9c41029..afe264c 100644 --- a/src/test/c/Tim/test_SchereSteinPapier.c +++ b/src/test/c/Tim/test_SchereSteinPapier.c @@ -16,6 +16,6 @@ void testingCeedlingFunctionality() { int expectedResult = 1; - int actualResult = schereSteinPapier(); + int actualResult = 1; TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } \ No newline at end of file From edaeb98d0a6f80b4e40fd8a64a475baef40eb2cc Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 15:29:47 +0100 Subject: [PATCH 02/17] =?UTF-8?q?Implementation=20der=20zuf=C3=A4lligen=20?= =?UTF-8?q?Computerauswahl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index d71250a..72d76fc 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -1,5 +1,7 @@ #include "SchereSteinPapier.h" #include +#include +#include void schereSteinPapier() @@ -19,7 +21,9 @@ void schereSteinPapier() } else if(user == 1 || user == 2 || user == 3) { - //do something + srand(time(NULL)); + com = rand() % 3 + 1; + printf("%d\n",com); } else { From 58e6b3018bd42428bc3fdd8f8991c9e4e562fe9e Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 18:47:09 +0100 Subject: [PATCH 03/17] Implementation der Berechnung des Gewinners --- src/main/c/Tim/SchereSteinPapier.c | 51 +++++++++++++++++++++++++++++- src/main/c/Tim/SchereSteinPapier.h | 1 + 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 72d76fc..6862522 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -17,13 +17,24 @@ void schereSteinPapier() scanf("%d", &user); if(user == 0) { + printf("Vielen Dank fürs Spielen! Tschau!\n"); break; } else if(user == 1 || user == 2 || user == 3) { srand(time(NULL)); com = rand() % 3 + 1; - printf("%d\n",com); + int win = calculateWinner(user, com); + switch (win) + { + case(-1):printf("Der Computer hat %d gewaehlt, Du hast verloren!!!\n\n", com); + break; + case(0): printf("Der Computer hat %d gewaehlt, Es steht unentschieden!!!\n\n", com); + break; + case(1): printf("Der Computer hat %d gewaehlt, Du hast gewonnen!!!\n\n", com); + break; + default: printf("Error!"); + } } else { @@ -31,3 +42,41 @@ void schereSteinPapier() } } } + + +int calculateWinner(int x, int y) +{ + switch (x) + { + case(1): + switch (y) { + case(1): return 0; + + case(2): return -1; + + case(3): return 1; + + default: return 3; + } + case(2): + switch (y) { + case(1): return 1; + + case(2): return 0; + + case(3): return -1; + + default: return 3; + } + case(3): + switch (y) { + case(1): return 1; + + case(2): return -1; + + case(3): return 0; + + default: return 3; + } + } +} \ No newline at end of file diff --git a/src/main/c/Tim/SchereSteinPapier.h b/src/main/c/Tim/SchereSteinPapier.h index 35c884b..a96c9f9 100644 --- a/src/main/c/Tim/SchereSteinPapier.h +++ b/src/main/c/Tim/SchereSteinPapier.h @@ -2,5 +2,6 @@ #define SCHERESTEINPAPIER_H void schereSteinPapier(); +int calculateWinner(int, int); #endif From feab52722beb1e39400bf6cda3b0d3af5c37b861 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 18:49:16 +0100 Subject: [PATCH 04/17] =?UTF-8?q?Implementation=20der=20Tests=20f=C3=BCr?= =?UTF-8?q?=20Testfall=20Unentschieden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/c/Tim/test_SchereSteinPapier.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/test/c/Tim/test_SchereSteinPapier.c b/src/test/c/Tim/test_SchereSteinPapier.c index afe264c..5a65733 100644 --- a/src/test/c/Tim/test_SchereSteinPapier.c +++ b/src/test/c/Tim/test_SchereSteinPapier.c @@ -12,10 +12,28 @@ void tearDown(void) } -void testingCeedlingFunctionality() +void test_drawScissorScissor() { - int expectedResult = 1; + int expectedResult = 0; + + int actualResult = calculateWinner(1,1); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_drawRockRock() +{ + int expectedResult = 0; + + int actualResult = calculateWinner(2,2); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} +void test_drawPaperPaper() +{ + int expectedResult = 0; + + int actualResult = calculateWinner(3,3); - int actualResult = 1; TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } \ No newline at end of file From bc7ba1d0a6a908e426e91b52bea930e80309cf29 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 18:51:52 +0100 Subject: [PATCH 05/17] =?UTF-8?q?Implementation=20der=20Tests=20f=C3=BCr?= =?UTF-8?q?=20den=20Testfall=20'Verloren'=20+=20Korrektur=20im=20Produktiv?= =?UTF-8?q?code=20bei=20der=20Ergebnisberechnung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 4 ++-- src/test/c/Tim/test_SchereSteinPapier.c | 27 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 6862522..3b71014 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -70,9 +70,9 @@ int calculateWinner(int x, int y) } case(3): switch (y) { - case(1): return 1; + case(1): return -1; - case(2): return -1; + case(2): return 1; case(3): return 0; diff --git a/src/test/c/Tim/test_SchereSteinPapier.c b/src/test/c/Tim/test_SchereSteinPapier.c index 5a65733..6707100 100644 --- a/src/test/c/Tim/test_SchereSteinPapier.c +++ b/src/test/c/Tim/test_SchereSteinPapier.c @@ -35,5 +35,32 @@ void test_drawPaperPaper() int actualResult = calculateWinner(3,3); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_lose_USER_Scissor_COM_Rock() +{ + int expectedResult = -1; + + int actualResult = calculateWinner(1,2); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_lose_USER_Paper_COM_Scissor() +{ + int expectedResult = -1; + + int actualResult = calculateWinner(3,1); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_lose_USER_Rock_COM_Paper() +{ + int expectedResult = -1; + + int actualResult = calculateWinner(2,3); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } \ No newline at end of file From 87b5a7d42a7f71349b0dc3f9c3b622e5418cfae2 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 18:53:31 +0100 Subject: [PATCH 06/17] =?UTF-8?q?Implementation=20der=20Test=20f=C3=BCr=20?= =?UTF-8?q?den=20Testfall=20'Sieg'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/c/Tim/test_SchereSteinPapier.c | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/c/Tim/test_SchereSteinPapier.c b/src/test/c/Tim/test_SchereSteinPapier.c index 6707100..bbe81fe 100644 --- a/src/test/c/Tim/test_SchereSteinPapier.c +++ b/src/test/c/Tim/test_SchereSteinPapier.c @@ -62,5 +62,31 @@ void test_lose_USER_Rock_COM_Paper() int actualResult = calculateWinner(2,3); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} +void test_Win_USER_Scissor_COM_Paper() +{ + int expectedResult = 1; + + int actualResult = calculateWinner(1,3); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_Win_USER_Rock_COM_Scissor() +{ + int expectedResult = 1; + + int actualResult = calculateWinner(2,1); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_Win_USER_Paper_COM_Rock() +{ + int expectedResult = 1; + + int actualResult = calculateWinner(3,2); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } \ No newline at end of file From 73943582ed2fef7c42d788acef3df763ca71de5f Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 18:55:44 +0100 Subject: [PATCH 07/17] =?UTF-8?q?Implementation=20der=20Tests=20f=C3=BCr?= =?UTF-8?q?=20den=20Testfall=20ungueltige=20Parameter=C3=BCbergabe=20bei?= =?UTF-8?q?=20calculateWinner()=20+=20Korrektur=20im=20Prodktivcode=20(Ein?= =?UTF-8?q?f=C3=BCgen=20von=20Default=20bei=20=C3=A4u=C3=9Ferer=20Switch)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 6 +++- src/test/c/Tim/test_SchereSteinPapier.c | 38 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 3b71014..12b9735 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -43,7 +43,9 @@ void schereSteinPapier() } } - +//Berechnung,welche Auswahl gewinnt. +//@return: 0 = unentschieden; 1 = gewonnen; -1 = verloren; 3 = Fehler bei der Wertübergabe +//@param x = UserChoice; y = COMChoice int calculateWinner(int x, int y) { switch (x) @@ -78,5 +80,7 @@ int calculateWinner(int x, int y) default: return 3; } + default: return 3; } + } \ No newline at end of file diff --git a/src/test/c/Tim/test_SchereSteinPapier.c b/src/test/c/Tim/test_SchereSteinPapier.c index bbe81fe..2b1d348 100644 --- a/src/test/c/Tim/test_SchereSteinPapier.c +++ b/src/test/c/Tim/test_SchereSteinPapier.c @@ -1,5 +1,6 @@ #include "SchereSteinPapier.h" #include "unity.h" +#include void setUp(void) { @@ -88,5 +89,42 @@ void test_Win_USER_Paper_COM_Rock() int actualResult = calculateWinner(3,2); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + + +void test_USER_unknownParameter_Rock_randomChoice() +{ + int expectedResult = 3; + + int actualResult = calculateWinner(5,rand() % 3 + 1); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_USER_randomChoice_Rock_unknownParameter() +{ + int expectedResult = 3; + + int actualResult = calculateWinner(rand() % 3 + 1, 5); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_USER_randomChoice_Rock_zero() +{ + int expectedResult = 3; + + int actualResult = calculateWinner(rand() % 3 + 1, 0); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_USER_zero_Rock_randomChoice() +{ + int expectedResult = 3; + + int actualResult = calculateWinner(0, rand() % 3 + 1); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } \ No newline at end of file From 8c90131f903ef33f23bcc684afc1da7439abc4f8 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 18:57:45 +0100 Subject: [PATCH 08/17] =?UTF-8?q?refactoring:=20Einheitliche=20Benennung?= =?UTF-8?q?=20der=20Test,=20Strukturierung=20nach=20Testf=C3=A4llen=20und?= =?UTF-8?q?=20Kommentierung=20der=20Tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/c/Tim/test_SchereSteinPapier.c | 118 +++++++++++++++--------- 1 file changed, 73 insertions(+), 45 deletions(-) diff --git a/src/test/c/Tim/test_SchereSteinPapier.c b/src/test/c/Tim/test_SchereSteinPapier.c index 2b1d348..23e6143 100644 --- a/src/test/c/Tim/test_SchereSteinPapier.c +++ b/src/test/c/Tim/test_SchereSteinPapier.c @@ -12,119 +12,147 @@ void tearDown(void) } - -void test_drawScissorScissor() +//Testfälle für Unentschieden +//1. Beide wählen Schere +void test_draw_USER_Scissor_COM_Scissor() { + //arrange int expectedResult = 0; - + //act int actualResult = calculateWinner(1,1); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } - -void test_drawRockRock() +//2. Beide wählen Stein +void test_draw_USER_Rock_COM_Rock() { + //arrange int expectedResult = 0; - + //act int actualResult = calculateWinner(2,2); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } -void test_drawPaperPaper() +//3. Beide wählen Papier +void test_draw_USER_Paper_COM_Paper() { + //arrange int expectedResult = 0; - + //act int actualResult = calculateWinner(3,3); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } + +//Testfälle für Niederlage +//1. User wählt Schere, Computer wählt Stein void test_lose_USER_Scissor_COM_Rock() { + //arrange int expectedResult = -1; - + //act int actualResult = calculateWinner(1,2); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } - +//2. User wählt Papier, Computer wählt Schere void test_lose_USER_Paper_COM_Scissor() { + //arrange int expectedResult = -1; - + //act int actualResult = calculateWinner(3,1); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } - +//3. User wählt Stein, Computer wählt Papier void test_lose_USER_Rock_COM_Paper() { + //arrange int expectedResult = -1; - + //act int actualResult = calculateWinner(2,3); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } -void test_Win_USER_Scissor_COM_Paper() + + +//Testfälle für Sieg +//1. User wählt Schere, Computer wählt Papier +void test_win_USER_Scissor_COM_Paper() { + //arrange int expectedResult = 1; - + //act int actualResult = calculateWinner(1,3); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } - -void test_Win_USER_Rock_COM_Scissor() +//2. User wählt Stein, Computer wählt Schere +void test_win_USER_Rock_COM_Scissor() { + //arrange int expectedResult = 1; - + //act int actualResult = calculateWinner(2,1); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } - -void test_Win_USER_Paper_COM_Rock() +//3. User wählt Papier, Computer wählt Stein +void test_win_USER_Paper_COM_Rock() { + //arrange int expectedResult = 1; - + //act int actualResult = calculateWinner(3,2); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } -void test_USER_unknownParameter_Rock_randomChoice() +//Testfälle für ungültige Parameterübergabe +//1. Durch den User wurde ein ungültiges Parameter übergeben +// Der Computer wählt eine Zahl zwischen 1 und 3 +void test_error_USER_unknownParameter_Rock_randomChoice() { + //arrange int expectedResult = 3; - + //act int actualResult = calculateWinner(5,rand() % 3 + 1); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } - -void test_USER_randomChoice_Rock_unknownParameter() +//2. Der User wählt eine Zahl zwischen 1 und 3 +// Durch den Computer wurde ein ungültiges Parameter übergeben +void test_error_USER_randomChoice_Rock_unknownParameter() { + //arrange int expectedResult = 3; - + //act int actualResult = calculateWinner(rand() % 3 + 1, 5); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } - -void test_USER_randomChoice_Rock_zero() +//3. Der User wählt eine Zahl zwischen 1 und 3 +// Durch den Computer wurde das ungültige Parameter 0 übergeben +void test_error_USER_randomChoice_Rock_zero() { + //arrange int expectedResult = 3; - + //act int actualResult = calculateWinner(rand() % 3 + 1, 0); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } - -void test_USER_zero_Rock_randomChoice() +//4. Durch den User wurde das ungültige Parameter 0 übergeben +// Der Computer wählt eine Zahl zwischen 1 und 3 +void test_error_USER_zero_Rock_randomChoice() { + //arrange int expectedResult = 3; - + //act int actualResult = calculateWinner(0, rand() % 3 + 1); - + //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } \ No newline at end of file From 6021ee8e0ab116e3a94923a7d1ea84fd28245a53 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 18:59:29 +0100 Subject: [PATCH 09/17] =?UTF-8?q?refactoring:=20Einf=C3=BChren=20der=20kon?= =?UTF-8?q?stanten=20Variablen=20scissor,=20rock,=20paper=20f=C3=BCr=20die?= =?UTF-8?q?=20Nutzung=20in=20den=20Tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/c/Tim/test_SchereSteinPapier.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/test/c/Tim/test_SchereSteinPapier.c b/src/test/c/Tim/test_SchereSteinPapier.c index 23e6143..485a07b 100644 --- a/src/test/c/Tim/test_SchereSteinPapier.c +++ b/src/test/c/Tim/test_SchereSteinPapier.c @@ -2,6 +2,10 @@ #include "unity.h" #include +const int scissor = 1; +const int rock = 2; +const int paper = 3; + void setUp(void) { @@ -19,7 +23,7 @@ void test_draw_USER_Scissor_COM_Scissor() //arrange int expectedResult = 0; //act - int actualResult = calculateWinner(1,1); + int actualResult = calculateWinner(scissor,scissor); //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } @@ -29,7 +33,7 @@ void test_draw_USER_Rock_COM_Rock() //arrange int expectedResult = 0; //act - int actualResult = calculateWinner(2,2); + int actualResult = calculateWinner(rock,rock); //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } @@ -39,7 +43,7 @@ void test_draw_USER_Paper_COM_Paper() //arrange int expectedResult = 0; //act - int actualResult = calculateWinner(3,3); + int actualResult = calculateWinner(paper,paper); //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } @@ -52,7 +56,7 @@ void test_lose_USER_Scissor_COM_Rock() //arrange int expectedResult = -1; //act - int actualResult = calculateWinner(1,2); + int actualResult = calculateWinner(scissor,rock); //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } @@ -62,7 +66,7 @@ void test_lose_USER_Paper_COM_Scissor() //arrange int expectedResult = -1; //act - int actualResult = calculateWinner(3,1); + int actualResult = calculateWinner(paper,scissor); //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } @@ -72,7 +76,7 @@ void test_lose_USER_Rock_COM_Paper() //arrange int expectedResult = -1; //act - int actualResult = calculateWinner(2,3); + int actualResult = calculateWinner(rock,paper); //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } @@ -85,7 +89,7 @@ void test_win_USER_Scissor_COM_Paper() //arrange int expectedResult = 1; //act - int actualResult = calculateWinner(1,3); + int actualResult = calculateWinner(scissor,paper); //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } @@ -95,7 +99,7 @@ void test_win_USER_Rock_COM_Scissor() //arrange int expectedResult = 1; //act - int actualResult = calculateWinner(2,1); + int actualResult = calculateWinner(rock,scissor); //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } @@ -105,7 +109,7 @@ void test_win_USER_Paper_COM_Rock() //arrange int expectedResult = 1; //act - int actualResult = calculateWinner(3,2); + int actualResult = calculateWinner(paper,rock); //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } From 4411a4b1e66f0074f6768a3d6209ee0145ea1417 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:06:32 +0100 Subject: [PATCH 10/17] =?UTF-8?q?refactoring:=20Verst=C3=A4ndlichere=20Ben?= =?UTF-8?q?ennung=20einiger=20Variablen:=20in=20schereSteinPapier():=20use?= =?UTF-8?q?r->userChoice,=20com->comChoice,=20win->winNum;=20formale=20Var?= =?UTF-8?q?iable=20in=20calculateWinner():=20x->userSelection,=20y->comSel?= =?UTF-8?q?ection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 12b9735..a0c9509 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -11,27 +11,27 @@ void schereSteinPapier() "Gibst du bei der Aufforderung 0 ein, gelangst du zurueck ins Hauptmenue!\n\n"); while(1) { - int com, user; + int comChoice, userChoice; printf("Bitte treffe deine Wahl!\n" "1: Schere \n2: Stein \n3: Papier\n0: Spiel verlassen\n"); - scanf("%d", &user); - if(user == 0) + scanf("%d", &userChoice); + if(userChoice == 0) { - printf("Vielen Dank fürs Spielen! Tschau!\n"); + printf("Vielen Dank fuers Spielen! Tschau!\n"); break; } - else if(user == 1 || user == 2 || user == 3) + else if(userChoice == 1 || userChoice == 2 || userChoice == 3) { srand(time(NULL)); - com = rand() % 3 + 1; - int win = calculateWinner(user, com); - switch (win) + comChoice = rand() % 3 + 1; + int winNum = calculateWinner(userChoice, comChoice); + switch (winNum) { - case(-1):printf("Der Computer hat %d gewaehlt, Du hast verloren!!!\n\n", com); + case(-1):printf("Der Computer hat %d gewaehlt, Du hast verloren!!!\n\n", comChoice); break; - case(0): printf("Der Computer hat %d gewaehlt, Es steht unentschieden!!!\n\n", com); + case(0): printf("Der Computer hat %d gewaehlt, Es steht unentschieden!!!\n\n", comChoice); break; - case(1): printf("Der Computer hat %d gewaehlt, Du hast gewonnen!!!\n\n", com); + case(1): printf("Der Computer hat %d gewaehlt, Du hast gewonnen!!!\n\n", comChoice); break; default: printf("Error!"); } @@ -44,14 +44,14 @@ void schereSteinPapier() } //Berechnung,welche Auswahl gewinnt. -//@return: 0 = unentschieden; 1 = gewonnen; -1 = verloren; 3 = Fehler bei der Wertübergabe -//@param x = UserChoice; y = COMChoice -int calculateWinner(int x, int y) +//@return: 0 = unentschieden; 1 = gewonnen; -1 = verloren; 3 = Fehler bei der Wertuebergabe +//@param userSelection = UserChoice; comSelection = COMChoice +int calculateWinner(int userSelection, int comSelection) { - switch (x) + switch (userSelection) { case(1): - switch (y) { + switch (comSelection) { case(1): return 0; case(2): return -1; @@ -61,7 +61,7 @@ int calculateWinner(int x, int y) default: return 3; } case(2): - switch (y) { + switch (comSelection) { case(1): return 1; case(2): return 0; @@ -71,7 +71,7 @@ int calculateWinner(int x, int y) default: return 3; } case(3): - switch (y) { + switch (comSelection) { case(1): return -1; case(2): return 1; From 389a40da9bd8976781a425f6195b5bf8b22d9d41 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:07:50 +0100 Subject: [PATCH 11/17] =?UTF-8?q?=C3=84nderung=20Position=20der=20Initalis?= =?UTF-8?q?ierung=20von=20srand()=20um=20die=20Zuf=C3=A4lligkeit=20zu=20ga?= =?UTF-8?q?rantieren?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index a0c9509..8c917ae 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -6,6 +6,7 @@ void schereSteinPapier() { + srand(time(NULL)); printf("\nHallo und Willkommen zu Schere-Stein-Papier!\n\nIn diesem Spiel spielst du gegen einen COM Schere-Stein-Papier!\n" "Waehle, sobald dich die Konsole dazu auffordert, deine 'Waffe' aus, indem du die entsprechende Zahl eintippst.\n" "Gibst du bei der Aufforderung 0 ein, gelangst du zurueck ins Hauptmenue!\n\n"); @@ -22,7 +23,6 @@ void schereSteinPapier() } else if(userChoice == 1 || userChoice == 2 || userChoice == 3) { - srand(time(NULL)); comChoice = rand() % 3 + 1; int winNum = calculateWinner(userChoice, comChoice); switch (winNum) From 2020e967fc7a4f1af597cd82844ba820c603e681 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:12:12 +0100 Subject: [PATCH 12/17] =?UTF-8?q?refactoring:=20Auslagern=20der=20Funktion?= =?UTF-8?q?alit=C3=A4t=20zu=20den=20Funktionen=20selectCOMChoice(),=20getW?= =?UTF-8?q?elcomeMessage(),=20printResult()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 46 +++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 8c917ae..1117fba 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -3,13 +3,14 @@ #include #include +char* getWelcomeMessageSSP(); +int selectCOMChoice(); +void printResult(int, int); void schereSteinPapier() { srand(time(NULL)); - printf("\nHallo und Willkommen zu Schere-Stein-Papier!\n\nIn diesem Spiel spielst du gegen einen COM Schere-Stein-Papier!\n" - "Waehle, sobald dich die Konsole dazu auffordert, deine 'Waffe' aus, indem du die entsprechende Zahl eintippst.\n" - "Gibst du bei der Aufforderung 0 ein, gelangst du zurueck ins Hauptmenue!\n\n"); + printf("%s", getWelcomeMessageSSP()); while(1) { int comChoice, userChoice; @@ -23,18 +24,9 @@ void schereSteinPapier() } else if(userChoice == 1 || userChoice == 2 || userChoice == 3) { - comChoice = rand() % 3 + 1; + comChoice = selectCOMChoice(); int winNum = calculateWinner(userChoice, comChoice); - switch (winNum) - { - case(-1):printf("Der Computer hat %d gewaehlt, Du hast verloren!!!\n\n", comChoice); - break; - case(0): printf("Der Computer hat %d gewaehlt, Es steht unentschieden!!!\n\n", comChoice); - break; - case(1): printf("Der Computer hat %d gewaehlt, Du hast gewonnen!!!\n\n", comChoice); - break; - default: printf("Error!"); - } + printResult(winNum, comChoice); } else { @@ -83,4 +75,30 @@ int calculateWinner(int userSelection, int comSelection) default: return 3; } +} + +int selectCOMChoice() +{ + return rand() % 3 + 1; +} + +char* getWelcomeMessageSSP() +{ + return "\nHallo und Willkommen zu Schere-Stein-Papier!\n\nIn diesem Spiel spielst du gegen einen COM Schere-Stein-Papier!\n" + "Waehle, sobald dich die Konsole dazu auffordert, deine 'Waffe' aus, indem du die entsprechende Zahl eintippst.\n" + "Gibst du bei der Aufforderung 0 ein, gelangst du zurueck ins Hauptmenue!\n\n"; +} + +void printResult(int winNumb, int comSelect) +{ + switch (winNumb) + { + case(-1):printf("Der Computer hat %d gewaehlt, Du hast verloren!!!\n\n", comSelect); + break; + case(0): printf("Der Computer hat %d gewaehlt, Es steht unentschieden!!!\n\n", comSelect); + break; + case(1): printf("Der Computer hat %d gewaehlt, Du hast gewonnen!!!\n\n", comSelect); + break; + default: printf("Error!"); + } } \ No newline at end of file From cf943347d9d1df59cade13b0b383bd70de671460 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:16:03 +0100 Subject: [PATCH 13/17] =?UTF-8?q?=C3=9Cberarbeitung=20der=20Funktion=20pri?= =?UTF-8?q?ntResult(),=20damit=20die=20Auswahl=20des=20Computers=20als=20W?= =?UTF-8?q?ort=20statt=20als=20Zahl=20ausgegeben=20wird?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 1117fba..c1d26c9 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -2,6 +2,7 @@ #include #include #include +#include char* getWelcomeMessageSSP(); int selectCOMChoice(); @@ -89,16 +90,34 @@ char* getWelcomeMessageSSP() "Gibst du bei der Aufforderung 0 ein, gelangst du zurueck ins Hauptmenue!\n\n"; } + void printResult(int winNumb, int comSelect) { + char comWeapon[10]; + switch(comSelect) + { + case(1): + strcpy(comWeapon, "Schere"); + break; + case(2): + strcpy(comWeapon,"Stein"); + break; + case(3): + strcpy(comWeapon,"Papier"); + break; + default: + strcpy(comWeapon, "Not found"); + break; + } switch (winNumb) { - case(-1):printf("Der Computer hat %d gewaehlt, Du hast verloren!!!\n\n", comSelect); + case(-1):printf("Der Computer hat %s gewaehlt, Du hast verloren!!!\n\n", comWeapon); break; - case(0): printf("Der Computer hat %d gewaehlt, Es steht unentschieden!!!\n\n", comSelect); + case(0): printf("Der Computer hat %s gewaehlt, Es steht unentschieden!!!\n\n", comWeapon); break; - case(1): printf("Der Computer hat %d gewaehlt, Du hast gewonnen!!!\n\n", comSelect); + case(1): printf("Der Computer hat %s gewaehlt, Du hast gewonnen!!!\n\n", comWeapon); break; default: printf("Error!"); + break; } } \ No newline at end of file From 098c67d0def974ad31c04ad262b81bd895d03ac1 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:19:18 +0100 Subject: [PATCH 14/17] Erweiterung der Funktion printResult() mit ASCII-Art --- src/main/c/Tim/SchereSteinPapier.c | 124 +++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 5 deletions(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index c1d26c9..dada586 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -6,7 +6,9 @@ char* getWelcomeMessageSSP(); int selectCOMChoice(); -void printResult(int, int); +void printResult(int, int, int); + + void schereSteinPapier() { @@ -27,7 +29,7 @@ void schereSteinPapier() { comChoice = selectCOMChoice(); int winNum = calculateWinner(userChoice, comChoice); - printResult(winNum, comChoice); + printResult(winNum, comChoice, userChoice); } else { @@ -85,13 +87,13 @@ int selectCOMChoice() char* getWelcomeMessageSSP() { - return "\nHallo und Willkommen zu Schere-Stein-Papier!\n\nIn diesem Spiel spielst du gegen einen COM Schere-Stein-Papier!\n" + return "\nHallo und Willkommen zu Schere-Stein-Papier\n\n" + "In diesem Spiel spielst du gegen einen COM Schere-Stein-Papier!\n" "Waehle, sobald dich die Konsole dazu auffordert, deine 'Waffe' aus, indem du die entsprechende Zahl eintippst.\n" "Gibst du bei der Aufforderung 0 ein, gelangst du zurueck ins Hauptmenue!\n\n"; } - -void printResult(int winNumb, int comSelect) +void printResult(int winNumb, int comSelect, int userSelect) { char comWeapon[10]; switch(comSelect) @@ -109,6 +111,118 @@ void printResult(int winNumb, int comSelect) strcpy(comWeapon, "Not found"); break; } + if(userSelect == 1) + { + switch (comSelect) + { + case(1): + printf(" _______ _______\n" + "---' ____)____ ____(____ '---\n" + " ______) (______\n" + " __________) (__________\n" + " (____) (____)\n" + "---.__(___) (___)__.---\n" + " Scissor vs Scissor\n"); + break; + case(2): + printf(" _______ _______\n" + "---' ____)____ (____ '---\n" + " ______) (_____)\n" + " __________) (_____)\n" + " (____) (____)\n" + "---.__(___) (___)__.---\n" + " Scissor vs Rock\n"); + break; + case(3): + printf(" _______ _______\n" + "---' ____)____ ____(____ '----\n" + " ______) (______\n" + " __________) (_______\n" + " (____) (_______\n" + "---.__(___) (_________.---\n" + " Scissor vs Paper\n"); + break; + default: + printf("ungültige Eingabe\n"); + break; + } + } + else if(userSelect ==2) + { + switch (comSelect) + { + case(1): + printf(" _______ _______\n" + "---' ____) ____(____ '---\n" + " (_____) (______\n" + " (_____) (__________\n" + " (____) (____)\n" + "---.__(___) (___)__.---\n" + " Rock VS Scissor\n"); + break; + case(2): + printf(" _______ _______\n" + "---' ____) (____ '---\n" + " (_____) (_____)\n" + " (_____) (_____)\n" + " (____) (____)\n" + "---.__(___) (___)__.---\n" + " Rock VS Rock\n"); + break; + case(3): + printf(" _______ _______\n" + "---' ____) ____(____ '----\n" + " (_____) (______\n" + " (_____) (_______\n" + " (____) (_______\n" + "---.__(___) (_________.---\n" + " Rock VS Paper\n"); + break; + default: + printf("ungültige Eingabe\n"); + break; + } + } + else if(userSelect ==3) + { + switch (comSelect) + { + case(1): + printf(" _______ _______\n" + "---' ____)____ ____(____ '---\n" + " ______) (______\n" + " _______) (__________\n" + " _______) (____)\n" + "---.__________) (___)__.---\n" + " Paper VS Scissor\n"); + break; + case(2): + printf(" _______ _______\n" + "---' ____)____ (____ '---\n" + " ______) (_____)\n" + " _______) (_____)\n" + " _______) (____)\n" + "---.__________) (___)__.---\n" + " Paper VS Rock\n"); + break; + case(3): + printf(" _______ _______\n" + "---' ____)____ ____(____ '----\n" + " ______) (______\n" + " _______) (_______\n" + " _______) (_______\n" + "---.__________) (_________.---\n" + " Paper VS Paper\n"); + break; + default: + printf("ungültige Eingabe\n"); + break; + } + } + else + { + printf("ungültige Eingabe"); + } switch (winNumb) { case(-1):printf("Der Computer hat %s gewaehlt, Du hast verloren!!!\n\n", comWeapon); From c1e535f5e2a8b86a5a0e4eeee7565eccd181fdef Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:21:15 +0100 Subject: [PATCH 15/17] Erweiterung der Funktion getWelcomeMessageSSP() mit ASCII-Art --- src/main/c/Tim/SchereSteinPapier.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index dada586..59fbf05 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -87,7 +87,16 @@ int selectCOMChoice() char* getWelcomeMessageSSP() { - return "\nHallo und Willkommen zu Schere-Stein-Papier\n\n" + return "\nHallo und Willkommen zu\n\n" + " _____ _ _____ _____ _ \r\n" + " | __ \\ | | | __ \\ / ____| (_) \r\n" + " | |__) |___ ___| | __ | |__) |_ _ _ __ ___ _ __ | (___ ___ _ ___ ___ ___ _ __ ___ \r\n" + " | _ // _ \\ / __| |/ / | ___/ _` | '_ \\ / _ \\ '__| \\___ \\ / __| / __/ __|/ _ \\| '__/ __|\r\n" + " | | \\ \\ (_) | (__| < | | | (_| | |_) | __/ | ____) | (__| \\__ \\__ \\ (_) | | \\__ \\\r\n" + " |_| \\_\\___/ \\___|_|\\_\\ |_| \\__,_| .__/ \\___|_| |_____/ \\___|_|___/___/\\___/|_| |___/ \r\n" + " | | \r\n" + " |_| \n" + "credits to wynand1004\n\n" "In diesem Spiel spielst du gegen einen COM Schere-Stein-Papier!\n" "Waehle, sobald dich die Konsole dazu auffordert, deine 'Waffe' aus, indem du die entsprechende Zahl eintippst.\n" "Gibst du bei der Aufforderung 0 ein, gelangst du zurueck ins Hauptmenue!\n\n"; From af0fdc1487d685554eaa5d4e646ad72d18fef5f0 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:27:04 +0100 Subject: [PATCH 16/17] =?UTF-8?q?refactoring:=20Auslagern=20von=20Funktion?= =?UTF-8?q?alit=C3=A4t=20zu=20gameLoop()=20und=20getuserSelection(),=20um?= =?UTF-8?q?=20die=20=C3=9Cbersichtlichkeit=20zu=20verbessern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 59fbf05..828d337 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -4,9 +4,11 @@ #include #include +void gameLoop(); char* getWelcomeMessageSSP(); int selectCOMChoice(); void printResult(int, int, int); +int getuserSelection(); @@ -14,12 +16,15 @@ void schereSteinPapier() { srand(time(NULL)); printf("%s", getWelcomeMessageSSP()); + gameLoop(); +} + +void gameLoop() +{ while(1) { int comChoice, userChoice; - printf("Bitte treffe deine Wahl!\n" - "1: Schere \n2: Stein \n3: Papier\n0: Spiel verlassen\n"); - scanf("%d", &userChoice); + userChoice = getuserSelection(); if(userChoice == 0) { printf("Vielen Dank fuers Spielen! Tschau!\n"); @@ -37,7 +42,6 @@ void schereSteinPapier() } } } - //Berechnung,welche Auswahl gewinnt. //@return: 0 = unentschieden; 1 = gewonnen; -1 = verloren; 3 = Fehler bei der Wertuebergabe //@param userSelection = UserChoice; comSelection = COMChoice @@ -85,6 +89,16 @@ int selectCOMChoice() return rand() % 3 + 1; } +int getuserSelection() +{ + int userSelect; + printf("Bitte treffe deine Wahl!\n" + "1: Schere \n2: Stein \n3: Papier\n0: Spiel verlassen\n"); + scanf("%d", &userSelect); + + return userSelect; +} + char* getWelcomeMessageSSP() { return "\nHallo und Willkommen zu\n\n" From feebb4ebc612a11a708fbf641ebe27ed3afc2719 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:33:32 +0100 Subject: [PATCH 17/17] =?UTF-8?q?Anlegen=20der=20Dateien=20f=C3=BCr=20Hang?= =?UTF-8?q?man=20und=20Einbau=20in=20das=20Interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/hangman.c | 7 +++++++ src/main/c/Tim/hangman.h | 6 ++++++ src/main/c/main.c | 14 ++++++++------ src/test/c/Tim/test_hangman.c | 24 ++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 src/main/c/Tim/hangman.c create mode 100644 src/main/c/Tim/hangman.h create mode 100644 src/test/c/Tim/test_hangman.c diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c new file mode 100644 index 0000000..d49319b --- /dev/null +++ b/src/main/c/Tim/hangman.c @@ -0,0 +1,7 @@ +#include "hangman.h" +#include + +void hangman() +{ + printf("Hello World!"); +} diff --git a/src/main/c/Tim/hangman.h b/src/main/c/Tim/hangman.h new file mode 100644 index 0000000..cd17d02 --- /dev/null +++ b/src/main/c/Tim/hangman.h @@ -0,0 +1,6 @@ +#ifndef HANGMAN_H +#define HANGMAN_H + +void hangman(); + +#endif diff --git a/src/main/c/main.c b/src/main/c/main.c index 6af2d92..cbaccdc 100644 --- a/src/main/c/main.c +++ b/src/main/c/main.c @@ -11,7 +11,8 @@ //todo // Includiert hier euer .h-Datei für das entsprechende Spiel mit '#include "datei.h"' #include -#include "Tim/SchereSteinPapier.h" +#include "SchereSteinPapier.h" +#include "hangman.h" void openInterface(); @@ -31,7 +32,8 @@ void openInterface() // Vergesst das \n am Ende des Namens nicht!!! printf("\n\nHallo und willkommen bei unserer Spielesammlung!!!\n" "Du hast folgende Spiele zur Auswahl:\n\n" - "1: Schere-Stein-Papier\n"); + "1: Schere-Stein-Papier\n" + "2: Hangman\n"); printf("\nBitte waehle die Zahl des entsprechenden Spiels aus, um damit zu starten.\nAm Ende eines Spiels kannst du mit der Taste 0 wieder zurueck zum Hauptmenue kommen.\nIm Hauptmenue beendest du mit der Auswahl 0 das Programm \n\n"); scanf_s("%d", &selection); @@ -44,10 +46,10 @@ void openInterface() case(1): schereSteinPapier(); break; - /*case(2): - //Spiel() - break; - case(3): + case(2): + hangman(); + break; + /*case(3): //Spiel() break; case(4): diff --git a/src/test/c/Tim/test_hangman.c b/src/test/c/Tim/test_hangman.c new file mode 100644 index 0000000..2afdf17 --- /dev/null +++ b/src/test/c/Tim/test_hangman.c @@ -0,0 +1,24 @@ +#include "hangman.h" +#include "unity.h" + + + +void setUp(void) +{ + +} + +void tearDown(void) +{ + +} + +void test_ceedling_functionality() +{ + //arrange + int expectedResult = 0; + //act + int actualResult = 0; + //assert + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} \ No newline at end of file