{"id":3500,"date":"2020-11-09T12:40:33","date_gmt":"2020-11-09T12:40:33","guid":{"rendered":"http:\/\/onlineclassesguru.com\/?p=3500"},"modified":"2020-11-09T12:40:33","modified_gmt":"2020-11-09T12:40:33","slug":"tictactoe-java-code-project","status":"publish","type":"post","link":"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/","title":{"rendered":"TicTacToe java code Project"},"content":{"rendered":"<style type=\"text\/css\"><\/style><p>Task<br \/>\nEnhance and correct a Tic Tac Toe game. The game is intended to be played against a computer.<\/p>\n<p>The object TicTacToeBoard is initialized to indicate if the computer is the player 1 or player 2. Your task is to allow turns between the player and computer and to determine if a winner exists.<\/p>\n<p>Keyboard input implies using the Scanner object.<\/p>\n<p>Review Section 7.7 in the textbook.<\/p>\n<p>Ideally, do 1 task at a time and test the results. The tasks are arranged so that the previous work will help with your testing.<\/p>\n<p>The TicTacToeBoard class uses a Character class which is a wrapper class for char. It allows for the value null. Thus, the board values can be \u0091X\u0092,\u0092O\u0092 or null.<\/p>\n<p>Deliverables<br \/>\nSubmit the modified and corrected TicTacToe class and TicTacToeBoard class.<\/p>\n<p>Be sure to submit both files. If you neglect to include a file, you must email me the missing file before the due date.<\/p>\n<p>The file GuiBoard.java does not need to be included as there are no required changes.<\/p>\n<p>Program Assumptions<br \/>\nThe TicTacToeBoard is instantiated with the Computer as player 2. This setting also determines who is \u0091X\u0092 and who is \u0091O\u0092. \u0091X\u0092 always goes first.<\/p>\n<p>In the TicTacToe board will have null values in the \u0091squares\u0092 when started.<\/p>\n<p>Program Requirements<br \/>\n1. In the TicTacToe class and TicTacToeBoard class, modify the comment headers to include your name and student ID and semester.<\/p>\n<p>2. In the TicTacToe class, set the existing Long variable named securityCode with a value as defined below. The TicTacToeBoard instance will do these validations for you. The program must simply load a number that qualifies. You may need to test this several times to create a qualifying security code.<\/p>\n<p>a. securityCode must be a 16 digit number.<\/p>\n<p>b. securityCode must start with the digit 2.<\/p>\n<p>c. securityCode must not have sequential repeating digits.<\/p>\n<p>i. Such as \u00914\u0092 in 271744.<\/p>\n<p>d. securityCode must not have sequential incrementing or decrementing digits. The next digit in the code cannot be 1 digit higher or 1 digit lower<\/p>\n<p>i. Such as \u009145\u0092 in 27145.<\/p>\n<p>ii. Such as \u009154\u0092 in 27154.<\/p>\n<p>e. securityCode must contain every digit (0-9)<\/p>\n<p>f. Being that securityCode is a Long variable type, it must be defined with a following L.<\/p>\n<p>i. Long securityCode = 1234L.<\/p>\n<p>g. You may optionally define the security code value with underscores for readability.<\/p>\n<p>i. Long securityCode = 1234_4444_4444_4444L;<\/p>\n<p>h. Do not prompt for a security code, it must be coded inside the TicTacToe class.<\/p>\n<p>3. Create a loop in the TicTacToe class to play the game. This will be referred to as the \u0091main\u0092 loop for this process.<\/p>\n<p>a. Create an int variable for row position. This declaration should be done only once and before the loop starts.<\/p>\n<p>b. Create an int variable for column position. This declaration should be done before the loop starts.<\/p>\n<p>c. Inside the loop, do the following tasks<\/p>\n<p>i. Display \u0093Your Turn\u0094 and prompt to enter a row number (0-2) to place your TicTacToe square.<\/p>\n<p>ii. Prompt to enter a column number (0-2) to place your TicTacToe square.<\/p>\n<p>iii. Call the setValue() method of the TicTacToeBoard instance with the input given.<\/p>\n<p>1. setValue requires 2 parameters, Row and Column.<\/p>\n<p>2. setValue is a boolean value method. It generates a true or false result. If the setValue method returns false, it was unable to process the request. When this occurs, display \u0093Try again\u0094 and resume the loop at the beginning.<\/p>\n<p>iv. Call the method hasWinner() of the TicTacToeBoard instance.<\/p>\n<p>1. If hasWinner() returns true then<\/p>\n<p>a. Call the method theWinnerIs() of the TicTacToeBoard instance and display the value returned from theWinnerIs() method as in the example below.<\/p>\n<p>b. i.e. \u0093The winner is X\u0094<\/p>\n<p>c. Exit the loop.<\/p>\n<p>v. Call the method theComputersTurn() of the TicTacToeBoard instance. If this method returns a false value, display that \u0093The computer has forfeited\u0094 and exit the loop.<\/p>\n<p>vi. Do task iv again.<\/p>\n<p>d. After the loop is completed \u0096 display \u0093Game over\u0094 from the main() method.<\/p>\n<p>4. The method setValue() in the TicTacToeBoard class can be called with out of range numeric values and create a runtime error. Modify the setValue method so that it returns false if data passed is not in the range of possible values. (0 \u0096 2).<\/p>\n<p>5. The TicTacToeBoard class does not have a way to indicate that all entries are loaded. Create a public method named hasSquaresAvailable() in the the TicTacToeBoard class that will report true if there are available squares or false is the board is full. (Review the existing checkFirstPlay() method for a similar example.)<\/p>\n<p>a. Call this new method from the TicTacToe class inside the main loop.<\/p>\n<p>i. Do this before calling setValue().<\/p>\n<p>ii. Do this before calling theComputersTurn().<\/p>\n<p>iii. If there are no remaining spaces then:<\/p>\n<p>1. Display \u0093No Available spaces\u0094.<\/p>\n<p>2. Terminate the loop.<\/p>\n<p>6. The TicTacToeBoard class currently only checks rows and columns.<\/p>\n<p>XXX XOX<\/p>\n<p>OXO XOO<\/p>\n<p>OOX OOX<\/p>\n<p>It does not check diagonal values.<\/p>\n<p>XXO XOO<\/p>\n<p>OXX XOX<\/p>\n<p>OOX OXX<\/p>\n<p>a. Create a private method inside the TicTacToeBoard class named checkForDiagonalWin that will check for a possible diagonal win. This method does not need internal loops. Study how the private method checkRowOrColumnForWinner() works to understand what to look for. Be careful to check for null values before doing other compares as this can result in a null pointer exception.<\/p>\n<p>b. Call the method created above in step 8a from the theWinnerIs() method in the TicTacToeBoard class.<\/p>\n<p>5 points Extra Credit \u0096 Change the valid input range from 0 -2 to 1-3 for the row and column indicators as part of the processing in the TicTacToe class. Do not change the setValue method in the TicTacToeBoard class. All other work must be completed to receive extra credit.<\/p>\n<p><center><a href=\"http:\/\/onlineclassesguru.com\/orders\/ordernow\"><img decoding=\"async\" src=\"https:\/\/encrypted-tbn0.gstatic.com\/images?q=tbn:ANd9GcTyj99p60XCLyLk1htB7-1neRt8-2QdnenNlQ&usqp=CAU\"target=\"_http:\/\/onlineclassesguru.com\/orders\/ordernow\"\/><\/center><p>","protected":false},"excerpt":{"rendered":"<p>Task Enhance and correct a Tic Tac Toe game. The game is intended to be played against a computer. The object TicTacToeBoard is initialized to indicate if the computer is the player 1 or player 2. Your task is to allow turns between the player and computer and to determine if a winner exists. Keyboard&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3500","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>TicTacToe java code Project - onlineclassesguru<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TicTacToe java code Project - onlineclassesguru\" \/>\n<meta property=\"og:description\" content=\"Task Enhance and correct a Tic Tac Toe game. The game is intended to be played against a computer. The object TicTacToeBoard is initialized to indicate if the computer is the player 1 or player 2. Your task is to allow turns between the player and computer and to determine if a winner exists. Keyboard...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/\" \/>\n<meta property=\"og:site_name\" content=\"onlineclassesguru\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-09T12:40:33+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin_admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/onlineclassesguru.com\/#website\",\"url\":\"https:\/\/onlineclassesguru.com\/\",\"name\":\"onlineclassesguru\",\"description\":\"Cheap Professional coursework and reaction papers help\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/onlineclassesguru.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/#webpage\",\"url\":\"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/\",\"name\":\"TicTacToe java code Project - onlineclassesguru\",\"isPartOf\":{\"@id\":\"https:\/\/onlineclassesguru.com\/#website\"},\"datePublished\":\"2020-11-09T12:40:33+00:00\",\"dateModified\":\"2020-11-09T12:40:33+00:00\",\"author\":{\"@id\":\"https:\/\/onlineclassesguru.com\/#\/schema\/person\/1831fa4d28e47b468621cf27932f5742\"},\"breadcrumb\":{\"@id\":\"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/onlineclassesguru.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"TicTacToe java code Project\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/onlineclassesguru.com\/#\/schema\/person\/1831fa4d28e47b468621cf27932f5742\",\"name\":\"admin_admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/onlineclassesguru.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/429c8d043f7a770af242b0031e8b9f2b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/429c8d043f7a770af242b0031e8b9f2b?s=96&d=mm&r=g\",\"caption\":\"admin_admin\"},\"url\":\"https:\/\/onlineclassesguru.com\/index.php\/author\/admin_admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TicTacToe java code Project - onlineclassesguru","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/","og_locale":"en_US","og_type":"article","og_title":"TicTacToe java code Project - onlineclassesguru","og_description":"Task Enhance and correct a Tic Tac Toe game. The game is intended to be played against a computer. The object TicTacToeBoard is initialized to indicate if the computer is the player 1 or player 2. Your task is to allow turns between the player and computer and to determine if a winner exists. Keyboard...","og_url":"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/","og_site_name":"onlineclassesguru","article_published_time":"2020-11-09T12:40:33+00:00","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin_admin","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/onlineclassesguru.com\/#website","url":"https:\/\/onlineclassesguru.com\/","name":"onlineclassesguru","description":"Cheap Professional coursework and reaction papers help","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/onlineclassesguru.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/#webpage","url":"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/","name":"TicTacToe java code Project - onlineclassesguru","isPartOf":{"@id":"https:\/\/onlineclassesguru.com\/#website"},"datePublished":"2020-11-09T12:40:33+00:00","dateModified":"2020-11-09T12:40:33+00:00","author":{"@id":"https:\/\/onlineclassesguru.com\/#\/schema\/person\/1831fa4d28e47b468621cf27932f5742"},"breadcrumb":{"@id":"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/onlineclassesguru.com\/index.php\/2020\/11\/09\/tictactoe-java-code-project\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/onlineclassesguru.com\/"},{"@type":"ListItem","position":2,"name":"TicTacToe java code Project"}]},{"@type":"Person","@id":"https:\/\/onlineclassesguru.com\/#\/schema\/person\/1831fa4d28e47b468621cf27932f5742","name":"admin_admin","image":{"@type":"ImageObject","@id":"https:\/\/onlineclassesguru.com\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/429c8d043f7a770af242b0031e8b9f2b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/429c8d043f7a770af242b0031e8b9f2b?s=96&d=mm&r=g","caption":"admin_admin"},"url":"https:\/\/onlineclassesguru.com\/index.php\/author\/admin_admin\/"}]}},"_links":{"self":[{"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/posts\/3500"}],"collection":[{"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/comments?post=3500"}],"version-history":[{"count":2,"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/posts\/3500\/revisions"}],"predecessor-version":[{"id":3502,"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/posts\/3500\/revisions\/3502"}],"wp:attachment":[{"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/media?parent=3500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/categories?post=3500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/onlineclassesguru.com\/index.php\/wp-json\/wp\/v2\/tags?post=3500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}