Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Students also viewed these Databases questions

Question

Describe the appropriate use of supplementary parts of a letter.

Answered: 1 week ago