|
|
@ -4,9 +4,11 @@ |
|
|
|
#include <time.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
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" |
|
|
|