From 6c57d30492b8b84f491ec5a53ad73bf9cfa5685a Mon Sep 17 00:00:00 2001 From: Diana Date: Tue, 16 Jun 2015 22:08:17 -0400 Subject: [PATCH] This is my homework! --- HangPerson/HangPerson/main.m | 124 ++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/HangPerson/HangPerson/main.m b/HangPerson/HangPerson/main.m index 948dd70..9be239d 100644 --- a/HangPerson/HangPerson/main.m +++ b/HangPerson/HangPerson/main.m @@ -11,7 +11,129 @@ int main(int argc, const char * argv[]) { @autoreleasepool { - // code goes here... + printf("Hang Person!\n\n"); + + char myWord[] = "coder"; + char yourWord[] = "_____"; + int maxNrOfInput = 0; + +// BOOL correct=YES; +// if ((yourWord[0]=='c')&&(yourWord[1]=='o')&&(yourWord[2]=='d')&&(yourWord[3]=='e')&&(yourWord[4]=='r')) { +// correct = YES; } +// else correct= NO; + + + + printf("Let's Play Hangman!\n\nI'm thinking of a word. Can you guess it?\n"); + + while (maxNrOfInput <10){ + char letterInput; + + printf("\n\nSelect a letter: "); + scanf("%s", &letterInput); + + // if the input is + if (letterInput==myWord[0]) { + (yourWord[0]=letterInput); + + + // if you win + if ((yourWord[0] == myWord[0]) && (yourWord[1] == 'o')&&(yourWord[2]=='d')&&(yourWord[3]=='e')&&(yourWord[4]=='r')) { + printf("\n<<< "); + for (int i=0; i>>"); + printf ("\n\nCONGRATS YOU WON!!!"); + break; + } + + else { + for (int i=0; i>>"); + printf ("\n\nCONGRATS YOU WON!!!"); + break; + } + else { + for (int i=0; i>>"); + printf ("\n\nCONGRATS YOU WON!!!"); + break; + } + else { + for (int i=0; i>>"); + printf ("\n\nCONGRATS YOU WON!!!"); + break; + } + else { + for (int i=0; i>>"); + printf ("\n\nCONGRATS YOU WON!!!"); + break; + } + else { + for (int i=0; i