2023 Pennfoster 402596 A Solution In this project you ll create data types | Assignment Collections

Computer Science 2023 Pennfoster 402596 – A+ Solution

2023 Pennfoster 402596 A Solution In this project you ll create data types | Assignment Collections

Pennfoster 402596 – A+ Solution

In 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 thePlayer, 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.

  1. Add an enumeration named Player to the games.board package. You could add Empty Java File or choose Java Enumas 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. 
  2. 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 Boardclass 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()) {

 

                  str.append(“|”);

             }

             str.append(“n”);

         }

return str.toString(); }

}

}

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(“ “);

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 theStringBuilder class by visiting the Oracle Website at http://docs.oracle.com/javase/ tutorial/java/data/buffers.html

 

  1. Add the following import statement to the BoardGameTester class: 
    import games.boards.*; 
  2. In the main() method of BoardGameTester, perform the following actions: 
    1. Create a 3 × 3 board for a Tic-Tac-Toe game. 
    2. Create a 6 × 7 board for a Connect Four game. 
    3. Create a 5 × 8 board for a game of Mastermind. 
    4. Set a cell to a nought or cross on the Tic-Tac-Toe board. 
    5. Set a cell to yellow or red on the Connect Four board. 
    6. Set a cell to yellow, red, green, blue, magenta, or orange on the Mastermind board. 
    7. Display the boards for Tic-Tac-Toe, Connect Four, and Mastermind. 
  3. 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

 

 

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational