Question: Let me try this... I have my classes for piece, and square I need to create a board class to join these classes togeather, for

Let me try this...

I have my classes for piece, and "square" I need to create a board class to join these classes togeather, for a Connect 4 game. I will post the code under the requirements. Thanks,

Create a Connect 4 game with Java

Proper error handling

Exception handling:

If you expect me to enter a number, and I enter "test" you should be able to handle this.

Gracefully exiting doesn't count.

Data validating:

If your board has a boundary of 10X10 and I enter 11 you should handle this.

If I enter a piece that doesn't exist on the board you should handle this.

The program should compile and run with minimal effort from me.

A simple CLI interface:

You need to display the board after EVERY turn. That way I can see what's going on.

The board must be displated at the end of each turn.

The full rules of Connect 4 must be implemented.

Add color to each piece so I can tell which one is which and move correcrtly.

Add a simple AI that I can play against. This can literally be a random number guessed between 1-8 (assuming that's how big connect fours board is)

The following classes must be implemented:

1.Board

Please note I will create a Main class joining the board and checks from the board class to create a functioning Project. Thanks

My classes

public class Square { Piece piece; public Square() { piece = new Piece(); } public Square(Piece myPiece) { piece = myPiece; } public Piece getPiece() { return piece; } public void setPiece(Piece myPiece) { piece = myPiece; }

public class Piece {

String name; String color; public Piece(String myName, String myColor) { this.name = myName; this.color = myColor; } public void move(Board board, int x1, int y1, int x2, int y2) { board.removePieceFromSpace(x1, y1); board.setPieceOnSpace(this, x2, y2); }

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!