Вы находитесь на странице: 1из 9

Schmidt 1

Logan Schmidt March 3, 2014 ENGL 1102 Mrs. Waterhouse During the 1970's select people have been introduced to the world of programming. In this world there is nothing more than a black screen (command prompt) and little white letters appearing on the screen. Imagine holding a dictionary style book and looking up words after words in order for you attempt to use for a program to run. Keep in mind that the keyword might not even be what you are looking for. Such as the word print. Originally the word print would display the word or variable on the screen. This word was very commonly and loosely used around the programming community. But it was not something that many people would remember using. This is due to a string of rules that is required after typing the word print. (Gillepsie, 1990) C number is one of the "easy languages" to learn. Due to the fact that the keywords the computer recognizes are the same words that we use. For example instead of remembering multiple rules about displaying something, you can just write cout. 'cout' means the computer's output(display) which is simple to use and is quick to type. 'cout' displays the very next thing that you type. C number was used to also enhance data flow. The data flow is the ability/ease of compiling (the part in actually creating the program)a file. The C number debugger (is a process that makes sure the computer understands everything you have typed. If there is something wrong it will tell you immediately where the problem is located and what the problem is) has also evolved to make it easier for users to understand. Originally the debuggers would only say that there is a problem not where it is located or what the problems are. (Jhonston, 2004) C number casually began to be overused without a clear look on adapting the original language. But undenounced to people they were already looking into the many problems of C number. C number could not handle many functions without failing due to speed of the execution (the speed of opening the actual program) of the program. Another big problem was storing big amounts of data into variables. Each number takes up 2-bits of data. 2-bits of data is nothing compared to the amount of space on a normal computer. (Hannan, 2010)

Schmidt 2
After constant use people have determined how obsolete that C number has truly been. The speed of compiling a code takes an extremely long time ex. (30 seconds). This has been bugging people along with the data flow problem. Thus in the early 90's there was work on updating C number. This version was going to have different keywords that are 'more' user friendly along with increasing the compiler speed. They completely removed some aspects of C number all together. This new version was thus referred to as C++. It still has the base language C number in the C++ coding bank but is not limited to just that. Any code that could be made in C number could now be instantly converted to C++ with no problems at all. But some people failed to understand that the C++ version is not always compatible with C number. This caused users to just instantly forget/degrade the original C number and is not referred to anymore today. It is now completely obsolete with its predecessor leading the way in being the new programming language. (Hannan, 2010) During 1995, C++ has begun to be taught in most public schools and has been available for most people to learn. For many years C++ had been the preferred coding language. It was simple and easy to use. Many people were able to pick it up quickly and learn how to use it. In my program, users are able to play the game tic-tac-toe with another person. A portion of this program has been written in C number and another portion has been written in C++ for the sake of dataflow. The code itself begins with initializing a board using an array. An array is a set amount of numbers that are going to be entered into the computer. All the numbers that can be entered can then be stored in the computer. This particular code is strictly used in C++ and is not compatible with C number. The next portion is the asking a player what move they would like to make. It switches players every turn between 1 and 2 using an older operator '?'. It varies the users after every turn and the symbol that they will use 'X' and 'O'. (Brereton, 1994) This program shows the user friendliness in both the program and the execution of the game. In the game it prompts the user for each move and it has a simplistic flow. The game itself refers to each players turn and prompts the players to make a move. While the programming style is not as simplistic as the execution it is fairly simple to understand. There is only one statement in each line of the program so its easier to understand. The flow is easy to manipulate and create. This helps for the execution time for the program and for others to read the code. (Expert, 1996)

Schmidt 3
This program was built for two purposes, to both entice people to follow the career of Computer Science and to inform people about the origins of the C languages. The program allows you to play a friendly game with another opponent or take apart the code piece by piece to analyze the aspects of each statement. Computer Science is a huge part of my life and I hope to change yours someday.

Schmidt 4
Works-Cited

Brereton, R. G. (1994). Object oriented Programming on Personal Computers. The Analyst, 119, 10, 2149. Retrieved from http://uncc.worldcat.org/title/object-oriented-programming-onpersonal-computers/oclc/1430106583829?referer=brief_results Expert C Programming. (1996). Ieee Software, 13, 4, 133. Retrieved from http://uncc.worldcat.org/title/expert-c-programming/oclc/86348842&referer=brief_results Gillepsie, T. (1990). Programming Languages. Library Journal, 115. 19. 120. Retrieved from http://uncc.worldcat.org/oclc/4595700856&referer=brief_results Hannan, M. (2010). Analysis on the evolution of the discourse on computer software and programming languages in the light of literary genres and POWER-KNOWLEDGE. Computers in Human Behavior, 26, 3, 464-473. Retrieved from http://uncc.worldcat.org/ title/analysis-on-the-evolution-of-the-discourse-on-computer-software-and-programming-languages-in-thelight-of-literary-genres-and-power-knowledge/oclc/539512 830&referer=brief_results Jhonston, W., Hanna, J. R., Millar, R. J. (2004). Advances in dataflow programming languages. ACM Computing Surveys (CSUR), 36. 1-34. Retrieved from: http://uncc.worldcat.org/oclc/4588587316&referer=brief_results

Schmidt 5

Everything after this point is code!!!


/* Name: Logan Schmidt Date: 3/12/14 Project: Multimodal Project Project Name: multimodal.cpp Algorithm: 1) Displays a board with numbers from 1-9 in sequential order. 2) Prompts players for the location of piece that they will place. 3) Users will input a number 1-9 that corresponds with the location they want their piece. 4) An X or O will appear in the selected space and display itself on the board. 5) Check board for three consecutive pieces in a line or if all locations are filled. 6) If there is a draw or win end game. 7) Repeat steps 2-6 until there is a winner or a draw. 8) Display winner. */ #include <iostream> using namespace std;

char Location[10]={'o','1','2','3','4','5','6','7','8','9'}; //empty locations that are displayed on the board

int win(); //a conditional function that checks if someone has gotten 3 in a row or if all locations are filled void board(); //a function that displays the new board with the pieces located on them

int main() //the first function that prompts the players for their moves { int player=1; int i; int move; //stores the users choices on the computer so the board can be displayed

char moves; //stores the users moves as well that can vary from turn to turn do //a command that executes the players to enter a number { board(); //displays the new board prior to all moves being made player=(player%2)?1:2; //gives the players identities that switch from turn to turn as player 1 and player 2 cout<<"Player "<<player<<", enter a number: "; //asks the user to input their first move cin>>move; //this is where the choice is temporarily stored before it is displayed on the board

Schmidt 6
moves=(player==1)?'X':'O'; or an 'O' if(move==1&&Location[1]=='1') //this command checks which location is chosen and stores it as a move which is sent to the display Location[1]=moves; else if(move==2&&Location[2]=='2') //this command checks which location is chosen and stores it as a move which is sent to the display Location[2]=moves; else if(move==3&&Location[3]=='3') //this command checks which location is chosen and stores it as a move which is sent to the display Location[3]=moves; else if(move==4&&Location[4]=='4') //this command checks which location is chosen and stores it as a move which is sent to the display Location[4]=moves; else if(move==5&&Location[5]=='5') //this command checks which location is chosen and stores it as a move which is sent to the display Location[5]=moves; else if(move==6&&Location[6]=='6') //this command checks which location is chosen and stores it as a move which is sent to the display Location[6]=moves; else if(move==7&&Location[7]=='7') //this command checks which location is chosen and stores it as a move which is sent to the display Location[7]=moves; else if(move==8&&Location[8]=='8') //this command checks which location is chosen and stores it as a move which is sent to the display Location[8]=moves; else if(move==9&&Location[9]=='9') //this command checks which location is chosen and stores it as a move which is sent to the display Location[9]=moves; else { cout<<"Invalid move "; //if you entered a number other than 1-9 the computer says Invalid move //this command checks to make sure you did not enter a number other than 1-9 //this command checks what player number you are and assigns the piece an 'X'

player--; //if you entered a number other than 1-9 it allows you to take another turn instead of skipping it all together cin.ignore(); //this command allows it so the board is not displayed again cin.get(); } i=win(); //every time the board is checked it is marked down and stored in the i value (so if its the second time being checked then i=2) //this command allows it so the board is not altered with this invalid move

player++; //after every turn the player number will increase, if the number is 2 and increases it will restart at 1 }while(i==-1); //this is a constraint that checks to see who won the game

Schmidt 7
board(); //this function obtains the board information and checks if there are 3 pieces in a row or if there is not

//if a person wins than i is immediately turned into 1 //if the board is filled the i stays at -1 if(i==1) //a statement that checks if i=1

cout<<"\aPlayer "<<--player<<" win "; //if i=1 then the player who won's name will be displayed else //a statement that checks if i is not equal to 1 cout<<"\aGame draw"; //if i is not equal to 1 than the game ends in a draw and it is displayed

cin.ignore(); //this command allows it so the board is not displayed again cin.get(); return 0; } /* Purpose: This function displays the board after every move is registered. After every turn the board will be re-displayed after every move. */ void board() { //this command allows it so the board is not altered with this invalid move //a required command that ends the program all together

cout<<"\tTic Tac Toe"<<endl; //displays the name of the game after every turn above the board cout<<"Do not type any letters or it will crash"<<endl; cout<<"Player 1 (X) - Player 2 (O)"<<endl<<endl; player cout<<endl; //displays the players pieces and what pieces are registered to each

cout<<" "<<Location[1]<<" "<<Location[2]<<" "<<Location[3]<<endl; //displays the top section of the board with the top three locations

cout<<endl;

cout<<" "<<Location[4]<<" "<<Location[5]<<" "<<Location[6]<<endl; //displays the mid section of the board with the middle three locations

cout<<endl;

cout<<" "<<Location[7]<<" "<<Location[8]<<" "<<Location[9]<<endl; //displays the bottom section of the board with the bottom three locations

cout<<endl;

Schmidt 8
} /* Purpose: This function checks the board to see if three of the same pieces are in a line. If there are three pieces in the line a 1 will be replaced with the i to make i=1. If all locations are filled on the board than i is replaced with a 0 so i=0 */ int win() { if(Location[1]==Location[2]&&Location[2]==Location[3]) //checks to make sure there are any pieces in location 1, 2, and 3

return 1; //replaces the i to make i=1 else if(Location[4]==Location[5]&&Location[5]==Location[6]) //checks to make sure there are any pieces in location 4, 5, and 6

return 1; //replaces the i to make i=1 else if(Location[7]==Location[8]&&Location[8]==Location[9]) //checks to make sure there are any pieces in location 7, 8, and 9

return 1; //replaces the i to make i=1 else if(Location[1]==Location[4]&&Location[4]==Location[7]) //checks to make sure there are any pieces in location 1, 4, and 7

return 1; //replaces the i to make i=1 else if(Location[2]==Location[5]&&Location[5]==Location[8]) //checks to make sure there are any pieces in location 2, 5, and 8

return 1; //replaces the i to make i=1 else if(Location[3]==Location[6]&&Location[6]==Location[9]) //checks to make sure there are any pieces in location 3, 6, and 9

return 1; //replaces the i to make i=1 else if(Location[1]==Location[5]&&Location[5]==Location[9]) //checks to make sure there are any pieces in location 1, 5, and 9

return 1; //replaces the i to make i=1 else if(Location[3]==Location[5]&&Location[5]==Location[7]) //checks to make sure there are any pieces in location 3, 5, and 7

return 1; //replaces the i to make i=1

Schmidt 9
else if(Location[1]!='1'&&Location[2]!='2'&&Location[3]!='3'&&Location[4]!='4'&&Location[5]!='5'&&Location[6]!='6'&&Location[7] !='7'&&Location[8]!='8'&&Location[9]!='9') //checks to make sure there are any pieces in location 1, 2, 3, 4, 5, 6, 7, 8, and 9 return 0; //replaces the i to make i=0 else //if there is an error with the program it will end the program with a draw return -1; //replaces the i to make i=-1 }

Вам также может понравиться