diff --git a/README.md b/README.md index 082e4ed..1765613 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Unit 0 Final Project +Henna and Kaisha All directions are here... https://github.com/accesscode-2-2/unit-0/tree/master/project diff --git a/TicTacToe/TicTacToe/main.m b/TicTacToe/TicTacToe/main.m index 3a713ee..82f951d 100644 --- a/TicTacToe/TicTacToe/main.m +++ b/TicTacToe/TicTacToe/main.m @@ -2,16 +2,366 @@ // main.m // TicTacToe // -// Created by Michael Kavouras on 6/25/15. -// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// Created by Henna and Kaisha on 6/27/15. // +//Henna: +//include a way to check for no more plays + +//Kaisha: +//keep track of players and score +//take in player's name and let them know they won + + #import +@interface ticTacToeManager : NSObject + +-(void) initializeArray: (int) dimension; +-(void) printBoard; +-(BOOL) isPositionValid: (int) horizontal And: (int) vertical AndIs: (char) userPosition WithUserType: (BOOL) isComputer; +-(BOOL) isWinner; +-(BOOL) isFull; + + + +@end + + + +@implementation ticTacToeManager{ + NSMutableArray *_board; +} + +-(void) initializeArray: (int) dimension{ + //NSMutableArray *array = [[NSMutableArray alloc]init]; + _board = [[NSMutableArray alloc] init]; + + for (int i = 0; i 3) { + NSLog(@"Please enter a valid position between 1 and 3"); + continue; + } + + NSLog(@"Choose your vertical position (1-3): "); + fpurge(stdin); + scanf("%d", &vPosition); + + if (vPosition < 1 || vPosition > 3) { + NSLog(@"Please enter a valid position between 1 and 3"); + continue; + } + } + + + // Pass in this position into our class and then check if it's empty and if so place this person's x or o into the board + + //if ([game isPositionValidX:hPosition AndY:vPosition and:xOrO userType:computerTurn ]){ + + //-(BOOL) isPositionValid: (int) horizontal And: (int) vertical AndIs: (char) userPosition WithUserType: (BOOL) isComputer; + + if([game isPositionValid: hPosition And: vPosition AndIs: xOrO WithUserType:computerTurn ]){ + if (onePlayer) { + if (computerTurn == YES) { + computerTurn = NO; + } + else{ + computerTurn = YES; + } + } + if (xOrO == 'X') { //After each iteration we want to change the postion to X or back to O + xOrO = 'O'; + } + else{ + xOrO = 'X'; + } + + [game printBoard]; + } + + won = [game isWinner]; + full = [game isFull]; + + if (won || full) { + break; + + } + else{ + continue; + } + } + + + + + while (true) { + char playAgain; + NSLog(@"Do you want to play again?(Y for yes and N for no: "); + fpurge(stdin); + scanf("%c", &playAgain); + + if ( (playAgain == 'y') || (playAgain == 'Y') ) { + playingAgain = YES; + break; + } + else if ((playAgain == 'n') || (playAgain == 'N')){ + + playingAgain = NO; + NSLog(@"Thanks for playing!"); + return 0; + + } + else{ + continue; + } + + } + + + } // end of playingAgain while LOOP + + } - return 0; + + //return 0; + + }