3 attachmentsSlide 1 of 3

  • attachment_1attachment_1
  • attachment_2attachment_2
  • attachment_3attachment_3

UNFORMATTED ATTACHMENT PREVIEW

Concentration For this assignment, we will complete Concentration. The most obvious change that we need to make is to give our “cards” a line of text. We can start by making an array of strings. You can hard code the values and you can use any (nonoffensive) text you want. Animals, colors, car models, whatever suits you. You need at least one string for every 2 cards. Next, you have to assign each card a text string, randomly, but making sure that each string gets 2 cards and each card gets a text string. This must be done in a function that is called at the beginning of each game. AcceptInput() needs to check the entered card numbers to make sure that they are valid (have not already been chosen, in range, etc.) UpdateWorld() must be modified to validate the matches correctly instead of our “5 matches 10” algorithm. It also must detect when the game is over (i.e. a valid match was made and there are no more matches). DisplayWorld() needs to be modified to show the available remaining card numbers. If the game is over, ask them if they want to play another. Set the global flag mentioned in main. You must keep track of the mapping between strings and cards by making a structure that holds the pointer to the text as well as other data you need (like, “was this chosen already”). Make an array of these structures. This array must be allocated dynamically (malloc) in Initialize and freed in TearDown(). You must submit buildable C source code to get credit for this assignment. Concentration Rubric Comments Poor OK Good Great None/Excessive (0) “What” not “Why”, few (5) Anything not obvious has reasoning (10) Variable/Function naming Structure Single letters everywhere (0) Lots of abbreviations (5) Some “what” comments or missing some (7) Full words most of the time (8) Indentation wrong OR Missing helper functions (7) Indentation correct, helper functions(10) Initialization Teardown AcceptInput UpdateWorld DisplayWorld String setup Card Randomization Globals everywhere, indentation doesn’t match braces {}, no helper functions (0) Doesn’t exist or is not called (0) Doesn’t exist (0) Does not check numbers (0) Doesn’t validates matches, doesn’t detect end of game (0) Doesn’t show valid cards or prompt for a new game (0) Doesn’t exist (0) Doesn’t exist(0) Either validates matches or detects end of game (5) Either shows valid cards OR prompts for a new game (5) Full words, descriptive (10) Exists, allocates memory (10) Exists, frees memory (10) Checks number validity (10) Validates matches and detects end of game (10) Shows valid cards and prompts for a new game (10) Exists, sized appropriately (10) Randomizes cards (10) Concentration Through the beginning of this semester, you will be building the board game Concetration. If you are not familiar with the game, it is very simple – a card has a number on the front (shown) and a line of text (or an image, but we won’t be using that). Each text will be the same on a pair of cards. The player can choose 2 cards at a time. If the text matches, the cards are removed. If not, the text is hidden and the player takes their next turn. The player’s goal is to find all of the pairs in the fewest possible number of turns. We will not be building a graphical use interface for this game (that isn’t the focus of this course) but we will be building a text interface to this game. For this assignment, we will be creating our project and getting some of the structure in place. Most computer games have a particular structure, whether “guess a number” or Battlefront II. They start with some initialization – set up the data structures that model the “game world”. Then there is the “game loop” – a (nearly) infinite loop that accepts user input, updates the state of the game world, and updates the display. Finally, there is the teardown sequence that happens at game exit. Initialization Accept Input Update State Game Loop Display World Game Over/Quit Teardown Concentration Your assignment: Create a program that models the structure above. Create functions: • • • • • • Initialization – print “Setting up the game”. Teardown – print “Destroying the game” Accept Input – accept two numbers, from 1 to some limit (I suggest 20 to 40, make sure it is even). Make sure that the person doesn’t pick the same number twice. 0 should quit the game (using the flag mentioned in “main”). Prompt the user so that they understand what you expect. Update the state of the world – pass the numbers to this function. Since we do not have a “world” right now, picking a number and its double (5 and 10, for example) is a match. This method must not print anything. It only does calculations. Results from here update the “global state.” This function should update a global score variable. Display the state of the world – Print the result calculated in the state of the world (match or no, score). Main – call initialization, then loop until a flag is set, calling accept input, update and display. Outside of the loop, call teardown. You should use a constant for the size of the board. You must submit buildable C source code to get credit for this assignment. Hints: Start early. Don’t wait until it is due – you won’t have time to ask questions or get help. Don’t write too much code – my solution is about 100 lines of code. If you go TOO much over that, you have done it really wrong. Shorter isn’t better, but longer isn’t better either. I suggest using scanf for input and printf for output. Write extra helper functions if you find yourself copy/pasting code. One mistake that people often make is to have AcceptInput call UpdateWorld which then calls DisplayState. This is not correct. Each of these functions are called by the game loop. There will be more assignments based on this assignment. Mistakes here will have to be fixed later! Concentration Rubric Comments Poor OK Good Great None/Excessive (0) “What” not “Why”, few (5) Anything not obvious has reasoning (10) Variable/Function naming Structure Single letters everywhere (0) Lots of abbreviations (5) Some “what” comments or missing some (7) Full words most of the time (8) Indentation wrong OR Missing helper functions (7) Indentation correct, helper functions(10) Initialization Teardown Game Loop Exit Game Loop Design Input Handling Display Globals everywhere, indentation doesn’t match braces {}, no helper functions (0) Doesn’t exist or is not called (0) Doesn’t exist (0) Doesn’t exist/Empty (0) Doesn’t Exist/Empty Doesn’t exist/Empty (0) Doesn’t exist/Empty (0) UpdateWorldState Doesn’t exist/Empty (0) Main Doesn’t exist (0) Full words, descriptive (10) Exists, is called (5) Exists, is called (5) Exists, doesn’t end (3) Calls some of the functions (5) Can input, no error handling (5) Prints with result set to global (5) Accepts Input (5) Exists, ends using break (7) Input with error handling (10) N/A Exists, ends without break (10) Calls all three functions (10) Input, error handling, prompting (15) Prints, result passed between methods (10) Accepts Input, “Calculates” properly (10) Exists and returns an exit value(5)

Do you similar assignment and would want someone to complete it for you? Click on the ORDER NOW option to get instant services at essayloop.com

Do you have a similar assignment and would want someone to complete it for you? Click on the ORDER NOW option to get instant services at essayloop.com. We assure you of a well written and plagiarism free papers delivered within your specified deadline.