n this project, you’ll create data types in a class structure for cell-based board games similar to Tic-Tac-Toe. Games like Connect Four and Mastermind also use boards divided by rows and columns. The Board and Cell classes represent the board, while the Player, Mark, and Outcome enumerations track the game. You’ll use the classes and enumerations created in this project in future graded projects. You use the NetBeans project in the next lesson. INSTRUCTIONS 1. In NetBeans, create a new Java Application project named BoardGameTester. 2. Create a new package named games and a sub-package of games named board. The easiest way is simply to create a package named games.board. 3. Add an enumeration named Player to the games.board package. You could add Empty Java File or choose Java Enum as the file type. This enumeration represents the current player in a turn-based game. Use the follow- ing code: public enum Player {FIRST,SECOND} Note: Although Tic-Tac-Toe and Mastermind allow only two players, Connect Four can be played with up to four players. For simplicity, our code will handle only two players. 4. Add an enumeration named Outcome to the games.board package. This enumeration represents the result when the turn is completed. Use the following code: public enum Outcome {PLAYER1_WIN, PLAYER2_WIN, CONTINUE, TIE} 5. Add an enumeration named Mark to the games.board package. This enumeration represents the result when the game is completed. Use the following code: public enum Mark {EMPTY, NOUGHT, CROSS, YELLOW, RED, BLUE, GREEN, MAGENTA, ORANGE} Note: Yellow and red are used in Connect Four, while Mastermind uses all six colors. 6. Add the Cell class to the games.board package. It should have the private variables content, row, and column, and the public methods getContent, setContent, getRow, and getColumn. Use the following code as a guide: public class Cell { private Mark content; private int row, column; public Cell(int row, int column) { this.row = row; this.column = column; content = Mark.EMPTY; } public Mark getContent() { return content; } public void setContent(Mark content) { this.content = content; } public int getRow() { return row; } public int getColumn() { return column; } } Note: All classes that support direct instantiation should have a constructor. In this case, the constructor will be used by the Board class to create each of its cells. 7. Add the Board class to the games.board package. It should have a two-dimensional array of Cell objects. The Board class should initialize a board with a specified number of columns and rows, provide access to Cell objects, and display all of its cells correctly. Use the following code as a guide: public class Board { private Cell[][] cells; public Board(int rows, int columns) { cells = new Cell[rows][columns]; for( int r = 0; r < cells[0].length; r++ ) { for (int c = 0; c < cells[1].length; c++) { cells[r][c] = new Cell(r,c); } } } public void setCell(Mark mark, int row, int column) throws IllegalArgumentException { if (cells[row][column].getContent() == Mark.EMPTY) cells[row][column].setContent(mark); else throw new IllegalArgumentException(“Player already there!”); } public Cell getCell(int row, int column) { return cells[row][column]; } public String toString() { StringBuilder str = new StringBuilder(); for( int r = 0; r < cells.length; r++ ) { str.append(“|”); for (int c = 0; c < cells[r].length; c++) { switch(cells[r][c].getContent()) { case NOUGHT: str.append(“O”); break; case CROSS: str.append(“X”); break; case YELLOW: str.append(“Y”); break; case RED: str.append(“R”); break; case BLUE: str.append(“B”); break; case GREEN: str.append(“G”); break; case MAGENTA: str.append(“M”); break; case ORANGE: str.append(“M”); break; default: //Empty str.append(“ “); } str.append(“|”); } str.append(“n”); } return str.toString(); } } Note: This code should seem familiar to you. The meth- ods in the TicTacToeGame class are similar to those in the Board class. The StringBuilder class was used instead of the String class for better performance. You can learn more about the StringBuilder class by visiting the Oracle Website at http://docs.oracle.com/javase/ tutorial/java/data/buffers.html. 8. Add the following import statement to the BoardGameTester class: import games.boards.*; 9. In the main() method of BoardGameTester, perform the following actions: a. Create a 3 × 3 board for a Tic-Tac-Toe game. b. Create a 6 × 7 board for a Connect Four game. c. Create a 5 × 8 board for a game of Mastermind. d. Set a cell to a nought or cross on the Tic-Tac-Toe board. e. Set a cell to yellow or red on the Connect Four board. f. Set a cell to yellow, red, green, blue, magenta, or orange on the Mastermind board. g. Display the boards for Tic-Tac-Toe, Connect Four, and Mastermind. 10. Compile and run the project to ensure it works as expected. SUBMISSION GUIDELINES To submit your project, you must provide the following source code files in a ZIP file: ■ BoardGameTester.java ■ Board.java ■ Cell.java ■ Mark.java ■ Outcome.java ■ Player.java
Why Work with Us
Top Quality and Well-Researched Papers
We ensure that all instructions are followed meticulously to deliver exactly what you need. You can select your academic level— high school, college/university, or professional— and we will match you with a writer who holds the relevant degree for your task.
Professional and Experienced Academic Writers
Our team of professional writers brings extensive experience in both academic and business writing. Many of our writers are native speakers, ensuring high-quality work for any task you need assistance with.
Free Unlimited Revisions
If you feel something is missing, don’t worry—send your order for a free revision! You have 10 days to request a review after receiving your final document. Simply log into your personal account or contact our support team to initiate the revision process. We’re committed to ensuring your complete satisfaction!
Prompt Delivery and 100% Money-Back-Guarantee
We are committed to delivering all papers on time. Should we require additional time to ensure your paper meets the highest standards, we will reach out to discuss a deadline extension. If an extension is not possible, we offer a 100% refund guarantee to ensure your satisfaction.
Original & Confidential
We utilize advanced writing tools to ensure that every document you receive is free from plagiarism and AI-generated content. Our expert editors meticulously review all citations and references within the text for accuracy. Additionally, we guarantee the highest level of confidentiality with all of our services, ensuring your privacy is always protected.
24/7 Customer Support
Our support agents are available 24/7, dedicated to providing you with the best customer experience. Feel free to reach out anytime you need assistance—we’re here to help!
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
Choose peace of mind. Choose Superior Custom Writers—your trusted partner for stress-free academic success!
Essays
No matter the type of academic paper you need or how urgent the deadline, we’ve got you covered! Choose your academic level and paper type, all at an affordable price. Our dedicated team handles all your paper needs while providing round-the-clock, 24/7 customer support for a seamless experience.
Admissions
Admission Essays Help
An admission essay is a critical component of your application, serving as a personal statement highlighting your unique qualities and aspirations for college, university, or graduate school. Our professional writing service,crafts an exceptional, compelling, and tailored admission essay that showcases your strengths and leaves a lasting impression. Let us help you stand out and secure your spot at your dream institution!
Reviews
Editing Support
Our team of expert academic writers and editors ensures your paper is thoroughly polished. We meticulously revise and refine your work, ensuring clarity and coherence. Additionally, we format your document according to your preferred style, including accurate citations and reference lists in APA, Harvard, MLA, Chicago, or Turabian formats.
Reviews
Revision Support
If you feel your paper could be improved, simply request a review. We will have the writer or an editor review your paper to ensure it meets your expectations. You can use this option as many times as needed, at no additional cost, because your satisfaction is our priority. We’re committed to delivering the best possible service, every time.