Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions