Question: You dont need to do tictactoe.java, because it is already done. Use the tictactoe example code to edit the connectfour.java. Please make sure to follow

You dont need to do tictactoe.java, because it is already done. Use the tictactoe example code to edit the connectfour.java. Please make sure to follow the approperiate steps in the task instructions.
Please edit the code in file Connectfour.java completely so the test file runs succesfully. Please don't just give me random verbal answers. Thank you
This is a java task that requires code editing, and code writing. The different code files are pasted below with file name specified ("--------filename").Thank you!
---------Player.java
public class Player {
private boolean human;
private String name;
private Player(boolean human, String name){
this.human = human;
this.name = name;
}
public static Player createHuman(String name){
return new Player(true, name);
}
public static Player createComputer(){
return new Player(false,"AI");
}
public boolean isHuman(){
return human;
}
public String getName(){
return name;
}
}
----------- TwoPlayerBoardGame.java
import java.util.Scanner;
import java.util.Random;
public abstract class TwoPlayerBoardGame {
protected static final Scanner console = new Scanner(System.in);
protected static final Random random = new Random();
protected final char[][] board;
private final int MAX_MOVES;
protected Player current;
private Player other;
protected TwoPlayerBoardGame(char[][] board, int MAX_MOVES, Player p1, Player p2){
this.board = board;
this.MAX_MOVES = MAX_MOVES;
this.current = p1;
this.other = p2;
}
public final void play(){
for (int i =0; i MAX_MOVES; ++i){
System.out.println(this);
do {
if (current.isHuman()){
askForMove();
receiveMove();
}
else {
generateMove();
}
}
while (!validMove());
applyMove();
if (someoneWon()){
System.out.println(this);
celebrateMove();
return;
}
else {
prepareForNextMove();
}
}
System.out.println(this);
System.out.println("It's a draw.");
}
protected abstract void askForMove();
protected abstract void receiveMove();
protected abstract void generateMove();
protected abstract boolean validMove();
protected abstract void applyMove();
protected abstract boolean someoneWon();
protected abstract void celebrateMove();
protected void prepareForNextMove(){
Player tmp = current;
current = other;
other = tmp;
}
}
----------- TestGames.java
public class TestGames {
public static void main(String[] args){
TwoPlayerBoardGame game;
game = new TicTacToe(Player.createHuman("Student"), Player.createComputer());
game.play();
game = new TicTacToe(Player.createHuman("Roy"), Player.createHuman("Moss"));
game.play();
game = new ConnectFour(Player.createHuman("Student"), Player.createComputer());
game.play();
game = new ConnectFour(Player.createHuman("Jen"), Player.createHuman("Moss"));
game.play();
}
}
----------- TicTacToe.java example to follow:
public final class TicTacToe extends TwoPlayerBoardGame {
private char XO ='X';
private int row;
private int col;
public TicTacToe(Player p1, Player p2){
super(new char[][]{{'','',''},{'','',''},{'','',''}},9, p1, p2);
}
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append('
');
for (int i =0; i 3; i++){
for (int j =0; j 3; j++){
sb.append(board[i][j]);
if (j 2) sb.append("|");
}
if (i 2){
sb.append("
-----
");
}
}
sb.append('
');
return sb.toString();
}
protected void askForMove(){
System.out.printl
----------- ConnectFour.java
public final class ConnectFour extends TwoPlayerBoardGame {
private char RY ='R';
private int col;
private static final int ROWS =6;
private static final int COLS =7;
public ConnectFour(Player p1, Player p2){
super(null,0, p1, p2);
}
public String toString(){
return "";
}
protected void askForMove(){
}
protected void receiveMove(){
}
protected void generateMove(){
}
protected boolean validMove(){
return true;
}
protected void applyMove(){
}
protected boolean someoneWon(){
return false;
}
protected void celebrateMove(){
}
protected void prepareForNextMove(){
}
 You dont need to do tictactoe.java, because it is already done.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!