Browse Source

refactoring: von you zu Player1

remotes/origin/Celine
Celine Khazarian 11 months ago
parent
commit
1642f8e2a9
  1. 30
      src/main/c/SchereSteinPapier.c

30
src/main/c/SchereSteinPapier.c

@ -3,24 +3,24 @@
#include <time.h>
#include <math.h>
int game(char you, char computer)
int game(char Player1, char computer)
{
if (you == '1' && computer == '1')
if (Player1 == '1' && computer == '1')
return -1;
if (you == '2' && computer == '2')
if (Player1 == '2' && computer == '2')
return -1;
if (you == '3' && computer == '3')
if (Player1 == '3' && computer == '3')
return -1;
if (you == '2' && computer == '3')
if (Player1 == '2' && computer == '3')
return 0;
else if (you == '3' && computer == '2') return 1;
if (you == '2' && computer == '1')
else if (Player1 == '3' && computer == '2') return 1;
if (Player1 == '2' && computer == '1')
return 1;
else if (you == '1' && computer == '2')
else if (Player1 == '1' && computer == '2')
return 0;
if (you == '3' && computer == '1')
if (Player1 == '3' && computer == '1')
return 0;
else if (you == '1' && computer == '3')
else if (Player1 == '1' && computer == '3')
return 1;
}
@ -32,7 +32,7 @@ int PVC() {
printf("\t\t\t\tName Spieler/in: ");
scanf("%s", Spieler);
while (ende[0] == 'W' || ende[0] == 'w') {
char you = 'Y', computer, Ergebnis;
char Player1 = 'Y', computer, Ergebnis;
srand(time(NULL));
n = rand() % 100;
if (n < 33) {
@ -43,12 +43,12 @@ int PVC() {
}
else {
computer = '1';
} while (you != '3' && you != '1' && you != '2') {
} while (Player1 != '3' && Player1 != '1' && Player1 != '2') {
printf("\n\n\n\n\t\t\t\tWaehlen Sie 1 fuer Schere, 2 fuer Stein oder 3 fuer Papier: \n\t\t\t\t\t\t\t");
scanf(" %c", &you);
scanf(" %c", &Player1);
}
Ergebnis = game(you, computer);
Ergebnis = game(Player1, computer);
if (Ergebnis == -1) {
printf("\n\n\t\t\t\tUnentschieden!\n\n");
@ -65,7 +65,7 @@ int PVC() {
}
printf("\t\t\t\tDu hast ausgesucht : %c und Computer hat ausgesucht : %c\n\n", you, computer);
printf("\t\t\t\tDu hast ausgesucht : %c und Computer hat ausgesucht : %c\n\n", Player1, computer);
printf("\t\t\t\tPunktestand: %s - %d, Computer - %d\n\n", Spieler, Punkte1, Punkte2);
printf("\t\t\t\tMoechten Sie weiter spielen oder beenden? (Weiter/Ende)\n\t\t\t\t");
scanf("%s", ende);

Loading…
Cancel
Save