From 01eed67c81ec6042952a1244e109c2b3028aaf86 Mon Sep 17 00:00:00 2001 From: Justine Gartner Date: Thu, 18 Jun 2015 23:15:13 -0400 Subject: [PATCH 1/4] first commit --- HangPerson/HangPerson/main.m | 71 +++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/HangPerson/HangPerson/main.m b/HangPerson/HangPerson/main.m index 948dd70..a5757d5 100644 --- a/HangPerson/HangPerson/main.m +++ b/HangPerson/HangPerson/main.m @@ -11,8 +11,75 @@ int main(int argc, const char * argv[]) { @autoreleasepool { - // code goes here... - + // I would like to add the option of playing again + // Some other words: + // Coconut + // Tropical + // Strawberry + + //I would also like to add a maximum number of guesses + + + char guessedLetter; + char secretWord1[7] = "unicorn"; + char blankSpaces1[7] = "_______"; + + int secretWord1Length = sizeof(secretWord1) / sizeof(char); + + + printf ("Let's play hangperson!\n\n"); + + + int wordComplete = 0; + + while(true) { + + //print current state of blank spaces + for (int k = 0; k < secretWord1Length; k++) { + printf("%c ", blankSpaces1[k]); + } + + // if all letters have been guessed. Game has been won. + if (wordComplete == 1){ + printf("\n\nYou're awesome. You got it."); + break; + } + + //print prompt, scan for user input + printf("\n\nGuess a letter:"); + scanf("%c", &guessedLetter); + + //set an integer to declare if any matches are found between the user's input and the secret word + int matches = 0; + wordComplete = 1; + + //compare user input to secret word, compare secret word to the current state of blank spaces + for (int i = 0; i < secretWord1Length; i++) { + + if (guessedLetter == secretWord1[i]){ + blankSpaces1[i] = guessedLetter; + matches = 1; + } + if (blankSpaces1[i] != secretWord1[i]){ + wordComplete = 0; + } + } + + if (matches == 1){ + printf("\nNice!\n"); + } + + if (matches == 0){ + printf("\nSorry, no '%c'\n\n", guessedLetter); + } + + + scanf("%c", &guessedLetter); + } + + + + } return 0; } From 6d786edc86bf0722dd0eb85a6eb1fd99f8b2dd25 Mon Sep 17 00:00:00 2001 From: Justine Gartner Date: Thu, 18 Jun 2015 23:16:44 -0400 Subject: [PATCH 2/4] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7f24b4d..55116ce 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ xcuserdata # Carthage/Checkouts Carthage/Build +.DS_Store From 59ae164db0fd5a11e60b675fa4fe029ac27b69f8 Mon Sep 17 00:00:00 2001 From: JustineKay Date: Thu, 18 Jun 2015 23:21:01 -0400 Subject: [PATCH 3/4] Update main.m --- HangPerson/HangPerson/main.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HangPerson/HangPerson/main.m b/HangPerson/HangPerson/main.m index a5757d5..99c337c 100644 --- a/HangPerson/HangPerson/main.m +++ b/HangPerson/HangPerson/main.m @@ -20,7 +20,7 @@ int main(int argc, const char * argv[]) { //I would also like to add a maximum number of guesses - char guessedLetter; + char guessedLette; char secretWord1[7] = "unicorn"; char blankSpaces1[7] = "_______"; From 1ef079abce904efc20860a3d9c69beeb64865332 Mon Sep 17 00:00:00 2001 From: Justine Gartner Date: Thu, 18 Jun 2015 23:22:59 -0400 Subject: [PATCH 4/4] remove bug --- HangPerson/HangPerson/main.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HangPerson/HangPerson/main.m b/HangPerson/HangPerson/main.m index 99c337c..a5757d5 100644 --- a/HangPerson/HangPerson/main.m +++ b/HangPerson/HangPerson/main.m @@ -20,7 +20,7 @@ int main(int argc, const char * argv[]) { //I would also like to add a maximum number of guesses - char guessedLette; + char guessedLetter; char secretWord1[7] = "unicorn"; char blankSpaces1[7] = "_______";