Answered step by step
Verified Expert Solution
Question
1 Approved Answer
. A C apas method - Given a Scammer, this method render ubject loput from the conned line and recurns & Location Tips and Tricks
. A C apas method - Given a Scammer, this method render ubject loput from the conned line and recurns & Location Tips and Tricks metlad that takes in a location and returns hoolman. _ True if the location is valid fle, on the board) and the location is an empespot - Fueil Le locali izid ur eply JL exciple olivlid localiu would be be spol 10,2 because there is a LOW 10 vur 3x3 rd. . a pitbad that talless in it Jucation and a letter, and returns a boolean - Thix mithor places the letter which should be an X ar D), in the specifix location. This should only happen if the location is valid Return the If placing thakor a succesful, falar if not Welvive prided the following public methods foe Board the gat. ANARATA method - Returns & GameSta r ting the current state of the me - Eller there was awer & le, or it's still ongoing the toStrica Iceloti - Returns a Saint representing the Curent game board - This might be a fal for printing out the current une board! It code where possible. Definitely check out the urethods we provide they are provided for rien! Cross methods and writica as nossary. The ones listed above or just themes we ruire. No M e w classes on oil in amende fins as that of office en el momentary Food for Thought TicTac Toe.java We will run this Java ile to play our game of Tic-Tac-Toe 1.c. this is my dry following methods. Make sure these methods are public Why should the board variable of c. 3oard object ben instance urinble! Wonka't this also work if it were static-1o, shared herren Nil Hoard obiccts? Well, imagine there were multiple game of T Tac Toc going on-gorans your onde was hacking a wehaltc. Tf baar: a static field, it would be shared among all imata of the class. All Roari ahorts would have the same Tic-Tac-Toe board.. deapite winting to play a Thai's cat what we want We wall al Board Le Bepaale. class). Implement the Example Output: HOW MANY playa (1 or 2) 7 1 Enter desired aquara for 1: 1,1 anaishod. - wize a Scaune dere - Callanetinud to p ut the wer for the bumber of players If there is one player, it will be player vs cucu gama If there ILTO l ayn, is will be a player vs player game Remember that Plnyer 1 is alwnys the Ice X, and Player 2 s nims the stor D. Tegin the mamc. Tirs: Orher mcshoda in the Tic Tac Toc class will be very chil here! Remember that we will to onde whenever posible COLlicue the Wabe uoti, cele 398 wul or there is a tic Once the game is over the proglu will cinis.lt will col pruuipt the user il Ley would like W ular a il a c hoc wlict simulates a use player wine with the counputer. Hins: Make sure you take advantage Direthods in the Burirdi Tir: Tic Toc classes. They are busy and mil. this rethodi such curier! - Create a Tic-Truc-Toc hod. - While the mmc isn't over, the player and the computer will take turns placing their letter X or a) cmpty s rs. R T to opt the player for where they want to - The player will be Plawe 1. The computer will always be Player 2. - Ou Player l's luit, le plus will print out the board. Il will peopl be planer for inpuli update the soul with the player's Love. - On the oil puter's tur, the CUCIPIT will ruducnly pick a capty are on the bord plus ins letrer cherc. - When the game is orcr, let the user lomow wha war or if it was i n In method which simulats a two-player grumc. lint: Make SUTC U take advantage of methods in the Board and Tic Tar The dears. They are handy and make this method much easier! - Create a Tic-Tru-Too hoard. While the game in tre prompt plays for where they want to go. Plnyers will take thens placing the letter for D) on empty qua - For each player's turn, the program will priul out tbe buurt. Then it will pupw ever's turu it is Jue ilul, sud uudale tue buen wila bal players love. - When the game is wver, Jut the user low wbu wur: or if it was a si We have provided the following methods for Tictactoe.java. . gatunberlayara method Civen Scanner, this method prompts the set and wong the wwwber of players The Ccoputer ie m e a more.. Later desired equire for 1: 2.1 Eater desired square for 1: 1,1 Enter desired square for 1: 9,4 Enter desired square for 1: 2.2 1011 The Corgter is waki 10 n ave. in order to help here are the m ark the of the popice wi l l pla d icho es of pokedjor oral sein! maleria del can be found a feste any other w a s so provided malerie for CS 1838 assisted your learning Real that comments esportal lines in Then the begin with // 101 Turn-In Procedure Enter desired square for 1: 0,0 TL 10 Submission To su bil, upload the file listed below to the diago n al u Gratitupe 10 IT Player 1 Wiac! Tictactoe.java Board.java Location. JAVA . GameState.java Make sure you we be n e "HWOL suulllu u lly run a basic wonder on YOUP NIKE c sed in the next next Allowed Imports tri llis puial Grade Cupe will IS preventivialinius of the you tay uy lumul java.util.Scanner aujas.util.Randco. You can submit na may AM A Y want before the deadline, so fool from to a mit ng yon mac substantial pro on the homenurk. We will oly me your last buiou: be ule w submit every file each time you ruuubuit. Checkstyle linumeo 15 points. If you see it in the wave fulder alle Gradescope Autograder You must run checkstyle on your subno . The checkstyle cap for this dul Love checks ylee, will woul d fi.ct you want checkentyll. I t is ur ixidu lile to: 3 JAVA -.jar checkasyle-8.28.jar yourF11 KAVAJAVA Startiak audit. Audit done. The ese above me here we w Chwylecrow. If you unauy croc, ley wulkswwu above this ressage, and the number at the end would be pula we would take odlucited by the cheestyle CILP mentioned above. The EVIL BLIX files wi! Niile intain Checlasty MIN. In fare homexories we will he increasing this ap p into the ait offing Shese style des Carly! For each submission, you will be able to the result of a low le test cases on your code. Each test typically cuerpoata subie iuet, at the cure U rupas tu peclure of your cute Uul these rubrics only. If y fuil tot, you can look at the out tu dute whunt WS Wrong and reshmit once you how find the to The Guadescope les seveski Pepe 1. Powet podista . Purot luckyle, Buple de 2. Provide basic sing and mange dator In other words, the rest on Grades per ty mprehensive. We are so theranghly test your code by sidering lys and write your own testle. You aleshore Avold sine radne Locopile, or cleate your bude you can do that locally OYUL Ich Other parts of your time he addyTArche in deine has to the output or Oradempe may not neeily rout your pade for the meet. Feature Restrictions There are a few features and thods in the inplity sho w are trying to teach or breaks OKT to grader. For the Town, do not a ny of the following in your final on the Teserved kyced System.exit Important Notes (Don't Skip) Collaboration Collaboration Statement Yon compilings will receives for all cated brici . Do not s mil.clasa files Test your code in w o n to the basic cheeks on Gruescape Sulit y al lui . Read the Allowed lots and scted but to avoid Check Pass for all the claritations die polats There that you acknowledge collaboration and give credit where credis ise, we require that you place a collaboration statement as a comment at the top of at least one java file that you submit. That col o n statement show her Tarbes on the homcar stigasi, who make Homework 04 - Tic-Tac-Toe Authors : Sumit Choudhury, Tejas Pradeep, Charlie King, Andrew Chafos, Vince Li, Julia Zhu, Shishir Bhat, Emma Barron Purpose This program is one of our first to use multiple classes and do more with the object-oriented part of "Object- Oriented Programming" We'll be breaking out of that static rut we've been in. This homework will give you experience coding some of the recently introduced concepts like arrays, static methods, instance data and methods, constructors, and toString. For this homework, we'll be using two primary classes, TicTacToe.java and Board.java. You won't be writing all the code in these classes. We were concerned that might be a bit much). Instead, we have provided some methods, and it's up to you to write the rest! As you code, be sure to think carefully about design. As programs grow in complexity, design becomes even more important, so be sure to follow good principles like encapsulation and modularity! Background Tic-Tac-Toe Rules 1. The game is played on a 3x3 grid. 2. Player 1 is the letter X, and Player 2 is the letter 0. Players take turns putting their marks in empty squares. 3. The first player to get 3 marks in a row (vertically across any column, horizontally along any row, or diagonally across any diagonal) is the winner. 4. When all 9 squares are full, the game is over. If no player has won, the game ends in a tie. Directions Read the entire PDF and the provided code. Make sure you completely understand the assignment before beginning. GameState.java Provided Java file. It is an enum representing the game's state - a win for Player 1, a win for Player 2, a tie, or an ongoing game. Do not modify this file. Location.java This Java file represents a given location on the board. It has two instance variables: row and column. For example, a Location object where the row is 2 and the column is 2 would represent the square at the bottom right of a Tic-Tac-Toe board. Because they are private, we cannot access them from outside the Location class. Therefore, implement the following getter methods in Location.java. Make these methods public. a getter for row, properly named (ie, getRow) a getter for column, properly named (ie, getColumn) Board.java This Java file represents our Tic-Tac-Toe board. Create a 2D character array called board to hold the current state of the Tic-Tac-Toe board. This board should be 3x3 and be an instance variable. When the game begins, the board should only hold empty spots. An empty spot is represented with a space character (' '). As players place their tokens, it should begin to fill with Xs and Os. Player 1 is X and Player 2 is D. You will implement the following public methods for Board. . A C apas method - Given a Scammer, this method render ubject loput from the conned line and recurns & Location Tips and Tricks metlad that takes in a location and returns hoolman. _ True if the location is valid fle, on the board) and the location is an empespot - Fueil Le locali izid ur eply JL exciple olivlid localiu would be be spol 10,2 because there is a LOW 10 vur 3x3 rd. . a pitbad that talless in it Jucation and a letter, and returns a boolean - Thix mithor places the letter which should be an X ar D), in the specifix location. This should only happen if the location is valid Return the If placing thakor a succesful, falar if not Welvive prided the following public methods foe Board the gat. ANARATA method - Returns & GameSta r ting the current state of the me - Eller there was awer & le, or it's still ongoing the toStrica Iceloti - Returns a Saint representing the Curent game board - This might be a fal for printing out the current une board! It code where possible. Definitely check out the urethods we provide they are provided for rien! Cross methods and writica as nossary. The ones listed above or just themes we ruire. No M e w classes on oil in amende fins as that of office en el momentary Food for Thought TicTac Toe.java We will run this Java ile to play our game of Tic-Tac-Toe 1.c. this is my dry following methods. Make sure these methods are public Why should the board variable of c. 3oard object ben instance urinble! Wonka't this also work if it were static-1o, shared herren Nil Hoard obiccts? Well, imagine there were multiple game of T Tac Toc going on-gorans your onde was hacking a wehaltc. Tf baar: a static field, it would be shared among all imata of the class. All Roari ahorts would have the same Tic-Tac-Toe board.. deapite winting to play a Thai's cat what we want We wall al Board Le Bepaale. class). Implement the Example Output: HOW MANY playa (1 or 2) 7 1 Enter desired aquara for 1: 1,1 anaishod. - wize a Scaune dere - Callanetinud to p ut the wer for the bumber of players If there is one player, it will be player vs cucu gama If there ILTO l ayn, is will be a player vs player game Remember that Plnyer 1 is alwnys the Ice X, and Player 2 s nims the stor D. Tegin the mamc. Tirs: Orher mcshoda in the Tic Tac Toc class will be very chil here! Remember that we will to onde whenever posible COLlicue the Wabe uoti, cele 398 wul or there is a tic Once the game is over the proglu will cinis.lt will col pruuipt the user il Ley would like W ular a il a c hoc wlict simulates a use player wine with the counputer. Hins: Make sure you take advantage Direthods in the Burirdi Tir: Tic Toc classes. They are busy and mil. this rethodi such curier! - Create a Tic-Truc-Toc hod. - While the mmc isn't over, the player and the computer will take turns placing their letter X or a) cmpty s rs. R T to opt the player for where they want to - The player will be Plawe 1. The computer will always be Player 2. - Ou Player l's luit, le plus will print out the board. Il will peopl be planer for inpuli update the soul with the player's Love. - On the oil puter's tur, the CUCIPIT will ruducnly pick a capty are on the bord plus ins letrer cherc. - When the game is orcr, let the user lomow wha war or if it was i n In method which simulats a two-player grumc. lint: Make SUTC U take advantage of methods in the Board and Tic Tar The dears. They are handy and make this method much easier! - Create a Tic-Tru-Too hoard. While the game in tre prompt plays for where they want to go. Plnyers will take thens placing the letter for D) on empty qua - For each player's turn, the program will priul out tbe buurt. Then it will pupw ever's turu it is Jue ilul, sud uudale tue buen wila bal players love. - When the game is wver, Jut the user low wbu wur: or if it was a si We have provided the following methods for Tictactoe.java. . gatunberlayara method Civen Scanner, this method prompts the set and wong the wwwber of players The Ccoputer ie m e a more.. Later desired equire for 1: 2.1 Eater desired square for 1: 1,1 Enter desired square for 1: 9,4 Enter desired square for 1: 2.2 1011 The Corgter is waki 10 n ave. in order to help here are the m ark the of the popice wi l l pla d icho es of pokedjor oral sein! maleria del can be found a feste any other w a s so provided malerie for CS 1838 assisted your learning Real that comments esportal lines in Then the begin with // 101 Turn-In Procedure Enter desired square for 1: 0,0 TL 10 Submission To su bil, upload the file listed below to the diago n al u Gratitupe 10 IT Player 1 Wiac! Tictactoe.java Board.java Location. JAVA . GameState.java Make sure you we be n e "HWOL suulllu u lly run a basic wonder on YOUP NIKE c sed in the next next Allowed Imports tri llis puial Grade Cupe will IS preventivialinius of the you tay uy lumul java.util.Scanner aujas.util.Randco. You can submit na may AM A Y want before the deadline, so fool from to a mit ng yon mac substantial pro on the homenurk. We will oly me your last buiou: be ule w submit every file each time you ruuubuit. Checkstyle linumeo 15 points. If you see it in the wave fulder alle Gradescope Autograder You must run checkstyle on your subno . The checkstyle cap for this dul Love checks ylee, will woul d fi.ct you want checkentyll. I t is ur ixidu lile to: 3 JAVA -.jar checkasyle-8.28.jar yourF11 KAVAJAVA Startiak audit. Audit done. The ese above me here we w Chwylecrow. If you unauy croc, ley wulkswwu above this ressage, and the number at the end would be pula we would take odlucited by the cheestyle CILP mentioned above. The EVIL BLIX files wi! Niile intain Checlasty MIN. In fare homexories we will he increasing this ap p into the ait offing Shese style des Carly! For each submission, you will be able to the result of a low le test cases on your code. Each test typically cuerpoata subie iuet, at the cure U rupas tu peclure of your cute Uul these rubrics only. If y fuil tot, you can look at the out tu dute whunt WS Wrong and reshmit once you how find the to The Guadescope les seveski Pepe 1. Powet podista . Purot luckyle, Buple de 2. Provide basic sing and mange dator In other words, the rest on Grades per ty mprehensive. We are so theranghly test your code by sidering lys and write your own testle. You aleshore Avold sine radne Locopile, or cleate your bude you can do that locally OYUL Ich Other parts of your time he addyTArche in deine has to the output or Oradempe may not neeily rout your pade for the meet. Feature Restrictions There are a few features and thods in the inplity sho w are trying to teach or breaks OKT to grader. For the Town, do not a ny of the following in your final on the Teserved kyced System.exit Important Notes (Don't Skip) Collaboration Collaboration Statement Yon compilings will receives for all cated brici . Do not s mil.clasa files Test your code in w o n to the basic cheeks on Gruescape Sulit y al lui . Read the Allowed lots and scted but to avoid Check Pass for all the claritations die polats There that you acknowledge collaboration and give credit where credis ise, we require that you place a collaboration statement as a comment at the top of at least one java file that you submit. That col o n statement show her Tarbes on the homcar stigasi, who make Homework 04 - Tic-Tac-Toe Authors : Sumit Choudhury, Tejas Pradeep, Charlie King, Andrew Chafos, Vince Li, Julia Zhu, Shishir Bhat, Emma Barron Purpose This program is one of our first to use multiple classes and do more with the object-oriented part of "Object- Oriented Programming" We'll be breaking out of that static rut we've been in. This homework will give you experience coding some of the recently introduced concepts like arrays, static methods, instance data and methods, constructors, and toString. For this homework, we'll be using two primary classes, TicTacToe.java and Board.java. You won't be writing all the code in these classes. We were concerned that might be a bit much). Instead, we have provided some methods, and it's up to you to write the rest! As you code, be sure to think carefully about design. As programs grow in complexity, design becomes even more important, so be sure to follow good principles like encapsulation and modularity! Background Tic-Tac-Toe Rules 1. The game is played on a 3x3 grid. 2. Player 1 is the letter X, and Player 2 is the letter 0. Players take turns putting their marks in empty squares. 3. The first player to get 3 marks in a row (vertically across any column, horizontally along any row, or diagonally across any diagonal) is the winner. 4. When all 9 squares are full, the game is over. If no player has won, the game ends in a tie. Directions Read the entire PDF and the provided code. Make sure you completely understand the assignment before beginning. GameState.java Provided Java file. It is an enum representing the game's state - a win for Player 1, a win for Player 2, a tie, or an ongoing game. Do not modify this file. Location.java This Java file represents a given location on the board. It has two instance variables: row and column. For example, a Location object where the row is 2 and the column is 2 would represent the square at the bottom right of a Tic-Tac-Toe board. Because they are private, we cannot access them from outside the Location class. Therefore, implement the following getter methods in Location.java. Make these methods public. a getter for row, properly named (ie, getRow) a getter for column, properly named (ie, getColumn) Board.java This Java file represents our Tic-Tac-Toe board. Create a 2D character array called board to hold the current state of the Tic-Tac-Toe board. This board should be 3x3 and be an instance variable. When the game begins, the board should only hold empty spots. An empty spot is represented with a space character (' '). As players place their tokens, it should begin to fill with Xs and Os. Player 1 is X and Player 2 is D. You will implement the following public methods for Board
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started