Networked Connect Four Game JavaFX | Source Code

Опубликовано: 27 Октябрь 2024
на канале: algopk
146
2

Source Code Available WhatsApp +923054957063
Description:
In this project you will implement the classic game of Connect Four. This is a somewhat
simple game to understand and play that most of you should be familiar with. Your
implementation will be a two player game where each player is a separate client and the
game is run by a server. Your server and clients will use the same machine; with the
server choosing a port on the local host and clients knowing the local host and port
number (just as was demonstrated in class). At the end of each game, each client will
be able to play again or quit.


All networking must be done utilizing Java Sockets (as shown in class). The server
must run on its own thread and handle each client on a separate thread. Each
client must connect and communicate with the server on a separate thread.
This project will be completed in two parts: Part #1 is the planning stage where you will
create a wireframe of your client user interface and well as a class diagrams for both the
server and client programs; with all of the classes, interfaces and relations you expect to
use in your code.
You may work in teams of two but do not have to.
How the game is played:
Connect Four is played on a grid of 7 columns and 6 rows (see image above). It is a two
player game where each player takes a turn dropping a checker into a slot (one of the
columns) on the game board. That checker will fall down the column and either land on
top of another checker or land on the bottom row.
To win the game, a player needs to get 4 of their checkers in a vertical, horizontal or
diagonal row before the other player (see image below):

For the server program logic:
It will only allow a game to start if there are two clients connected.
It will notify a client if they are the only one connected.
It will keep track of what each player played.
It will notify clients if there is a win or tie after every move.
It will update each client with the other clients move.
It will do all things necessary to run the game.
The Client program GUI:
You are welcome to use/discover any widget, pane, node, layout or other in JavaFX to
implement your GUI in addition to the required elements described above.
The following 3 scenes are required:
1) Your program must start with a welcome screen that is it’s own JavaFX scene.
It will consist of:
Your welcome screen should welcome players to the game and have some sort of
design other than the default color and style of JavaFX. In past semesters, this is a
good opportunity to use images as background and play with the style of the graphical
elements.
It will also allow the user to input the port number and ip address to connect to the
server. Once connected to the server, the client program will change the GUI to the
game play screen.
2) For the client game play screen:
An area to display if it is player one or player two’s turn to go
An area displaying each move made; with the following info for each move
which player made the move
where the move was made to on the board
if it was a valid move (if your program only allows valid moves, omit this)
The game board (see below for details on this)
For instance, if player one attempted to make the first move of the game in row 3,
column 3, you might print out to the GUI:
“Player one moved to 3,3. This is NOT a valid move. Player one pick again.”