Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS ALL IN JAVA. Below is the problem and solution that was created. It is running these erors, please help so that it doesn't

THIS IS ALL IN JAVA. Below is the problem and solution that was created. It is running these erors, please help so that it doesn't run these errors. I am using IntelliJ. The solution is typed in Java, and the screenshots of code is the starter code.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

This is the code I wrote that I need help with which is running errors:

import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class TicTacToe { // define constants for the symbols used in the game and the size of the board private static final char PLAYER_ONE_SYMBOL = 'X'; private static final char PLAYER_TWO_SYMBOL = 'O'; private static final char EMPTY_SYMBOL = '-'; private static final int BOARD_SIZE = 3; // declare instance variables for the game board, game history, and game mode private char[][] board; private ArrayList gameHistory; private boolean singlePlayer; private boolean playerOneTurn; // constructor for TicTacToe class public TicTacToe() { // initialize board and game history board = new char[BOARD_SIZE][BOARD_SIZE]; gameHistory = new ArrayList(); // set default game mode and starting player singlePlayer = false; playerOneTurn = true; // set up empty board initializeBoard(); } // method to initialize an empty board private void initializeBoard() { for (int i = 0; i   Program Description Your little brother achieved some amazing results thanks to your program. So you decide to reward him by making a game for him. In particular, he loves to play tictac-toe with you so you decide to build that. Furthermore, you want him to be able to compete against the computer as well as you. Hence, your game is going to have two modes: (i) single player mode (against the computer) and (ii) two player mode. In two player mode, your program should first ask the players their names and toss a coin to decide who goes first. Then the program should ask the users to take turns playing the game. Ensure that each move is legitimate and print the game result when someone wins or when the game ends in a draw. In one player mode, your program should first ask for the player's name. You will be playing with the computer. Then it should toss a coin to decide who gets to go first. Player one and player two refer to the order in which the players enter their names. Player one gets the 'X' character while player two gets the 'O' character. Player one does NOT refer to the player who takes the first turn, since it's based on a coin-flip. When playing one-player mode, the Al will always be player two. Lastly, the menu should repeat unless the user selects the quit option. Menu contains four options that user can select: I. 1. Single player > user will play with computer II. 2. Two player > user will play with another human player III. D. Display last match -> displays the last played match IV. Q. Quit -> user wish to quit the game, when selected you should display proper message. Refer to sample output for expected functionality. To get you started, this week we provide starter code in the form of an IntelliJ project folder, which has all the headers of the methods you'd must implement to create the program as well as more specific hints for doing so. You are required to use this starter code and you may modify it by adding additional methods, but do not change the existing methods provided. You can unzip the starter code file to get a project folder. Then, open this in IntelliJ and work with it as you would any other project. Make extensive use of methods to organize your code and break the problem down into manageable pieces. The starter code contains all the method headers you would need for this - the solution we wrote has all these methods and no more than these methods. Start with the two-player game since that'll be most similar to what you're familiar with and makes testing easier. After you have that, the only challenge with the one-player game will be implementing the Al algorithms, as the rest of the game logic will carry over and can be reused. You must use an ArrayList to store the game history, and you must use a 2D char array to store a game state. The starter code has three static variables in the TicTacToe class, which are used to centrally store what symbols in the game represent the empty space, the player one symbol, and the player two symbol. Throughout your code, you must refer to these static variables rather than hard coding the game to rely on '', 'X', and 'O'. You may not add additional static variables to the class. These are effectively used as configuration options for the game. Certain methods in the starter code are marked as private. Since we're only using one class, there is no functional difference. Later in the course you'll see why some have their access from other classes restricted in this way. All methods are static. You'll also see why when we cover what it means for methods and variables to be static in detail. Your program should conform to these edge-case expectations regarding user input: - In every menu, check whether the user's choice of menu option is valid and inform them if their choice isn't valid. - When inputting positions on the board, you do not need to handle non-numerical or non-integer inputs. Assume they will only input integers. However, you should check that the integers they inputted are valid. This means their input should both be within the 33 grid and should be an unoccupied space. Inform the user if their input was invalid and which of these two rules it broke. Deliverables \& Reminders The usual deliverables and reminders apply. Compress and submit your project folder to Canvas before the deadline (or after with penalty, per the syllabus). The more serious warnings are listed below, but of course past assignments have more detailed instructions. Ensure your submission contains the necessary file(s) and is the correct version of your code that you want graded. This is your warning. You will not be allowed to resubmit this assignment after the due date if you submit the wrong file. Remember that this is graded on accuracy, and this is a pair project. Plagiarism or cheating will be dealt with seriously. - (10pts) for iterating over the ArrayList to display each turn (7pts) Menu functionality throughout (2pts) for a menu system that takes user input, executes the appropriate code on valid entry and warns the user of invalid entry, repeating until user ends program - (3pts) for correct names input collection - the first name should be player one, the computer should be player two and be given a reasonable name, for example - (3pts) for not executing the replay unless a past game exists (5pts) for using static/global variables correctly throughout - (-1pt) per instance where a symbol was hardcoded rather than referring to appropriate static class char variable - (Opts) for this category if additional static variables are added

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions

Question

suggest a range of work sample exercises and design them

Answered: 1 week ago