From f6e5642ce34292e27f3e365ff4ea18a7c0fee23d Mon Sep 17 00:00:00 2001 From: Varindra Date: Thu, 18 Jun 2015 21:59:08 -0400 Subject: [PATCH] VarindraHart hangman --- HangPerson/.DS_Store | Bin 0 -> 6148 bytes HangPerson/HangPerson/main.m | 203 ++++++++++++++++++++++++++++++++++- 2 files changed, 198 insertions(+), 5 deletions(-) create mode 100644 HangPerson/.DS_Store diff --git a/HangPerson/.DS_Store b/HangPerson/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..644ed9fc3bdf4e40977a35cb958e8f3a1a72d45f GIT binary patch literal 6148 zcmeHKu}Z{15PhRp9N1i8VY!{1aDNbv2$sS%mP#TgVoXpEEYsUq`44`Mf8?8;Q7)K5 zEktw%cHU-pW_RX6c6R{CVqMRH8GtF9qG)GCba-@X%Z(>Q$!i?r95=W{i|dhve&dkF zzKbKAG2#_A<3GSXDrQnMr;b^*xV&1;msQ(zmdMG|SA3hcEbH}M1-v}(KjalYy>HXj z-}db;He-IY&_f3U!9Xw&4E$#XcxS6jcML-Z1HnKr@Xmmq4~b2&aO@59(Lt3<0HQvl zv#_tVg!&}M!m&5x3`NY9Xs+TVhL}6YliL-Jy`i~7y!a5``K@@7ygS!V*&I?Bh7JaT zfguCi_Bqr0|B%1TXpuj3iLYQF82Doh$fR7B3nt}v>xcC8u1##GY$|HkYlp)A;1R$N hJxBKPq|GPo)2?vr4RsYA&+f!{2xLM+1p`08z$?sDKN0`{ literal 0 HcmV?d00001 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