Please review file to see instructions
COP 2210Dr. Debra Davis Assignment 5: Tic-Tac-Toe For this assignment, you will be creating an interactive Tic-Tac-Toe game. You need to remember what you have learned in class, lab, books and your assignments. Be sure to refer to them when you need to. There are 2 parts to this assignment. In the first part, you are going to be given a problem and you will then need to create a structure, write algorithms and a flow chart to solve it. In the second part, you’ll be turning this into a java program. So let’s get started! Part 1: Your Tic-Tac-Toe game! You love playing tic-tac-toe, but don’t always have someone to play the game with. So, you decide to create your own that you can play against the computer. This will be a standard tic-tac-toe game with X’s and O’s where the players alternate taking turns placing their tokens (i.e., X or O, depending on which one they are). It will include: · Standard 3 x 3 playing board (required: use 2D arrays) · A winning game is either: · 3 across · 3 up and down · 3 diagonally · Tie games are possible if a winning game is not achieved. · The game board with associated placement of the played X’s and O’s must be displayed after each turn. Program Flow: · First, ask the user for their name and welcome them. · Then randomly decide who will go first, the user or the computer (and let the user know this) · The user and computer will alternate turns placing their tokens. · The user should be asked where they want to place their token · The computer should be asked to randomly choose an empty spot · The game ends when either a winning game occurs (see above) or all the spots are filled. · At the end of the game, ask the user if they would like to play again. Input Options: There are numerous options for getting input from users to indicate where they want their token placed. Option 1: Ask them to give you the column and row number of their desired spot. Option 2: Pre-fill each of the spots with a number, allowing users to select one number to indicate their desired spot. For example: 1 | 2 | 3 __|___|__ 4 | 5 | 6 __|___|__ 7 | 8 | 9 | | For Part 1, create a class structure, algorithms and flow chart for your program, and then do several iterations of tests (i.e., analyze it and step through to make sure that it is logically correct). Also write the pseudocode for your tester class (where your main will go). Put these in a Word or Open Office document. You’ll turn that document in with the program that you create in Part 2. REMINDER: You must comment your code and include JavaDocs documentation as part of your assignment. Important! As you are working on this, be sure to break this down into smaller pieces. Take it step-by-step, and don’t try to finish this in one sitting. It will make it MUST easier. Part 2: Creating your Tic-Tac-Toe program Once you are done revising and testing the class structure and algorithms, you are ready to start modifying the code! 1. You should already have a Netbeans project. If you only have the source code, you will need to create a project. Here’s a nice tutorial on how to do that in Netbeans. If you are using Dr. Java or Eclipse, just do a quick search on youtube.com and you’ll find lots of candidates. http://www.youtube.com/watch?v=ezUHG1cuxkM Be sure to give your project a nice, meaningful name (and make sure it adheres to Java’s naming conventions). 2. Once you have your shell ready, there are a few things to know before you start translating your algorithm into code · At the top of your class file, be sure to include the following: //******************************************************************************** // STUDENT NAME: [Your Name] // FIU EMAIL: [Your FIU email] // CLASS: COP 2210 – [Semester Year] // ASSIGNMENT # [#] // DATE: [Date] // // I hereby swear and affirm that this work is solely my own, and not the work // or the derivative of the work of someone else, except as outlined in the // assignment instructions. //******************************************************************************** 3. Now start translating your changes into java code. · Remember to code and then compile frequently. It will make it easier to find any bugs. · Also remember that you will need a separate tester class (where your main method will reside) if there is not already one. i. Include the following code at the top of your class file (so that you can use this class: import java.util.Random; To find out more about this, go to http://java.sun.com/javase/7/docs/api/index.html (like you did in Lab Assignment 2) ii. You’ll need to use some variables. Here’s how you get a random number: Upper limit of the random number generated Random r = new Random(); int x = 1 + r.nextInt(10); Note that the number in the parens (e.g., 10 above) is the upper limit of the random number. So, the random number that you get here will be an integer between 0 and 10. Need a larger range? Just change the 10 to the top of your range. Here’s another example, in this case if you are printing a random number to the console: System.out.print( 1 + r.nextInt(5) + " " ); 4. Here is one more thing to do. Any input requested from the user and/or output received from the user should be in a window (see E.1.14 and E.1.15 from lab 1). At this point, you probably have your output going to the console. For your final submission, it needs to go to a window (JOptionPane). Don’t forget any additional libraries that you need to import to do this. That’s it! Now you your own interactive Tic-Tac-Toe game! Of course, you’ll also need to turn it in to Moodle. Submission Requirements You must upload a zip file to Moodle that includes your complete source project in Netbeans, ready to load (We have been very lenient up until now regarding this. From this assignment on, you will lose points if you do not include your complete project.), and also contains the output in separate data files, and your Word/Open Office document with your algorithm. VERY IMPORTANT: If you do not provide output in separate, easy to find data files, I will assume that your program does not work on those test cases, and grade accordingly. Do not embed the output in your source code.