diff --git a/HangPerson/.DS_Store b/HangPerson/.DS_Store new file mode 100644 index 0000000..644ed9f Binary files /dev/null and b/HangPerson/.DS_Store differ diff --git a/HangPerson/HangPerson/main.m b/HangPerson/HangPerson/main.m index 948dd70..8e11ab7 100644 --- a/HangPerson/HangPerson/main.m +++ b/HangPerson/HangPerson/main.m @@ -1,18 +1,211 @@ // // main.m -// HangPerson +// hangman // -// Created by Michael Kavouras on 6/15/15. -// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// Created by Varindra Hart on 6/14/15. +// Copyright (c) 2015 Varindra Hart. All rights reserved. // #import int main(int argc, const char * argv[]) { @autoreleasepool { + // insert code here... + NSLog(@"Hello, World!\n\n"); + + //randomly select a word. take the words length using strlen. make two arrays of that length, one for the answer and the other for dashed lines; + char *words[10]= {"california","controller","navigate","spectacles","cinnamon","zucchini","abcissa","pulchritudinous","impasse","excalibur"}; + //choose index for a word + int start = arc4random_uniform(10); + //record the length of the chosen word + int wordlength = (int)strlen(words[start]); + //create character arrays to hold the answer word and a dashed line of equal length + char ans[wordlength]; + char dashed[wordlength]; + // + for (int i=0; i0){ + + if (counter==6 && printKey==0){ + printf("***************\n"); + printf("*.. _____ ....\n"); + printf("*..| | \n"); + printf("*..| \n"); + printf("*..| \n"); + printf("*..| \n"); + printf("*..| \n"); + printf("*..|...........\n"); + printf("___|___........\n"); + printf("...............\n"); + printKey++; + } + + int correct = 0; + char input[256]; + printf("\n%s\n",dashed); + printf("Guess a letter: "); + scanf("%255[^\n]%*c",input); + fpurge(stdin); + printf("\n"); + int inputLength=0; + + if(input[0] ==' '){ + printf("Don't put a space before your letter or word\n"); + continue; + } + + for (int j=0; j<256; j++){ + if(input[j]=='\0'){ + break; + } + inputLength++; + } + + if( inputLength == 1){ + for (int i=0; i-1){ + win = win + correct; + } + + if(inputLength==wordlength){ + int checker=0; + for (int k=0; k