Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Grid Based games such as tic-tac-toe, Connect 4, chess, checkers, battleship, sudoku, and crossword puzzles often represent the board on a 2 dimensional array of
Grid Based games such as tic-tac-toe, Connect 4, chess, checkers, battleship, sudoku, and crossword puzzles often represent the board on a 2 dimensional array of characters. For this assignment you'll be making a class that reads in a saved state of one of these games so that it could be used as a game loader. Once the game is loaded, a game can get a copy of the state from the Jagged Grid Reader and use it. The other half of this would be a JaggedGridWriter which is outside the scope of this assignment. For your version of the Jagged Grid Reader, Your solution will need to be more general than a rectangular grid. You'll be able to handle files that have differing numbers of columns. So, you'll need to use a two dimensional ragged array, and the file should not hold any meta-information about the shape of the grid such as its length and width. Instead, your program will treat each line in the file as one row of the grid and use the length of the string on that line as the number of characters for that row. Note: The grid will be stored verbatim, and the number of rows and columns will not be stored in the file. For example a grid could be used to store the state of a heads or tails game, so the grid would be a single character in a file for nothing, h for heads, or t for tails. A two player rock-paper-scissors game could be stored as two characters, each being for nothing, r for rock, p for paper, or s for scissors. Some examples of game representations follow: Heads-or-Tails 2 Player Rock-Paper-Scissors Tic-Tac-Toe Sudoku (solved) For this assignment, you'll be developing on java class and one java program that will test the class. The class that you will create is: - JaggedGridReader - an object for reading files into a 2-D array. When the JaggedGridReader constructor is called, it should, store the filename, read the specified file and convert it to a two dimensional array of characters and store it in the grid field. The tostring ( ) method should return a string that is identical to the contents of the file. getCopy() should return a deep copy of the grid or null if the file specified was not found. getFileName ( ) should return the file name specified on construction. The UML diagram for is below. In addition you should create a program in a file called GameFileTester. java that reads in a grid that represents your favorite grid based game that has at least 9 cells. Make sure to upload the file that your GameFileTester is reading. Also make sure that the program runs without any request for input or any need for command line arguments. Extra Credit: For up to 20 points of Extra Credit have your tester change the grid from the initial state that is read in to a winning game state. Both the initial state and the winning state should be printed below text in your output that says EXTRA CREDIT . The number of points awarded will be based on how the winning state was acheived. 5 points for a trivial change to the array. 10 points for changes to the array that involve a loop. 20 points for changes to the array based on simulating the game play. All extra credit should be based on your own solution and should not reference other sources. If you work on a team to do the extra credit, then you all must credit each other and the points will be distributed equally among those credited. Class description - an object for reading files into a 2-D array. - fields - grid: the two dimensional array that holds the file contents - fileName: the name of the file where the originated. - methods - JaggedGridReader () : When the constructor is called, it should, store the file name, read the specified file and convert it to a two dimensional array of characters and store it in the grid field. : this method should return a string that is identical to the contents of the file. - : this method should return a deep copy of the or if the file specified was not found. : this method should return the file name specified on construction. Submission When you submit your files to this repository they will be tested with the GitHub classroom autograding system. You can submit as many versions of each file until all of the tests pass. Submission When you submit your files to this repository they will be tested with the GitHub classroom autograding system. You can submit as many versions of each file until all of the tests pass. The first tests will test the on one file. There are 4 tests for 20 points each. The last tests will run GameFileTester. If GameFileTester runs, then you will get 20 points. If GameFileTester prints , then you will see 1 extra credit point and your extra credit will be evaluated by the instructor
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