|
@ -4,9 +4,11 @@ |
|
|
#include <time.h> |
|
|
#include <time.h> |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
|
|
void gameLoop(); |
|
|
char* getWelcomeMessageSSP(); |
|
|
char* getWelcomeMessageSSP(); |
|
|
int selectCOMChoice(); |
|
|
int selectCOMChoice(); |
|
|
void printResult(int, int, int); |
|
|
void printResult(int, int, int); |
|
|
|
|
|
int getuserSelection(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -14,12 +16,15 @@ void schereSteinPapier() |
|
|
{ |
|
|
{ |
|
|
srand(time(NULL)); |
|
|
srand(time(NULL)); |
|
|
printf("%s", getWelcomeMessageSSP()); |
|
|
printf("%s", getWelcomeMessageSSP()); |
|
|
|
|
|
gameLoop(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void gameLoop() |
|
|
|
|
|
{ |
|
|
while(1) |
|
|
while(1) |
|
|
{ |
|
|
{ |
|
|
int comChoice, userChoice; |
|
|
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) |
|
|
if(userChoice == 0) |
|
|
{ |
|
|
{ |
|
|
printf("Vielen Dank fuers Spielen! Tschau!\n"); |
|
|
printf("Vielen Dank fuers Spielen! Tschau!\n"); |
|
@ -37,7 +42,6 @@ void schereSteinPapier() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Berechnung,welche Auswahl gewinnt. |
|
|
//Berechnung,welche Auswahl gewinnt. |
|
|
//@return: 0 = unentschieden; 1 = gewonnen; -1 = verloren; 3 = Fehler bei der Wertuebergabe |
|
|
//@return: 0 = unentschieden; 1 = gewonnen; -1 = verloren; 3 = Fehler bei der Wertuebergabe |
|
|
//@param userSelection = UserChoice; comSelection = COMChoice |
|
|
//@param userSelection = UserChoice; comSelection = COMChoice |
|
@ -85,6 +89,16 @@ int selectCOMChoice() |
|
|
return rand() % 3 + 1; |
|
|
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() |
|
|
char* getWelcomeMessageSSP() |
|
|
{ |
|
|
{ |
|
|
return "\nHallo und Willkommen zu\n\n" |
|
|
return "\nHallo und Willkommen zu\n\n" |
|
|