Question: Create a game of tic tac toe with the following classes driving the game. The top half is what each function should do, and then

Create a game of tic tac toe with the following classes driving the game. The top half is what each function should do, and then the bottom half is where I have gotten so far. Using Java.

  • Game class
    • use Iboard type instead of a Board type
    • create a new constructor to accept Iboard
    • Use APlayer[] type , default is two computer player that select row and col randomly
  • MyBoard class (you can copy it from any source, or write your own MyBoard class)
  • MyBoardWrapper class
    • have a composition relation between MyBoard and the Wrapper
    • implement the Iboard interface
    • forward all the MyBoard methods to implements all the Iboard methods
  • Board class
    • implements the Iboard interface
  • Iboard Interface

    public interface Iboard {

    void print();

    void reset();

    String getMark(int row, int col);

    boolean makeMove(String player, int row, int col); //Originally we called it boxToMark

    void setSize(int row, int col);

    int getColSize();

    int getRowSize();

    String getName();

    boolean isFull();

    }

public class DriverMain {

public static void main(String[] args) {

TTTGame game = new TTTGame(new MyBoardWrapper());

OR

TTTGame game = new TTTGame(new Board()); }

}

class TTTGame {

TTTGame (MyBoardWrapper board){

}

}

class MyBoard {

MyBoard {

}

}

class MyBoardWrapper implements IBoard {

}

class Board {

Board {

}

}

public interface IBoard {

void print();

void reset();

String getMark(int row, int colm);

boolean makeMove(String player, int row, int colm);

void setSize(int row, int colm);

int getColSize();

int getRowSize();

String getName();

boolean isFull();

}

public class Game {

public static void main(String[] args) {

TTTGame game = new TTTGame(new MyBoardWrapper());

}

}

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!