You will be re-implementing the client side for the game of Connect Four as a graphical user interface (GUI). You will reuse the server design we used in the previous laboratory assignment, so the protocol and game rules are unchanged.
The design utilizes the Model-View-Controller pattern, on top of a network interface.
ConnectFourBoard plays the role of the model. It is an observable
subject, notifying any observer of any change in its state. Enough
public methods are included to help observers find out what that
ConnectFourGUI (or the provided
plays the role of both the view and controller, taking input from,
and sending output to, the user. The class also observes
the model in order to keep its visual display up to date. But in
addition, this class can tell from the board's state when it is
time for its user to choose a move. After that particular update
call, the part of the GUI that receives user input is briefly
enabled, and the resulting choice is directly communicated to the
network client for transmission to the server.
NetworkClient is the class responsible for network
communication. It opens the connection to the server, gets the
game parameters, and instructs the
ConnectFourBoard object to
finish its initialization accordingly. Note that this
class spawns a thread that listens for incoming server
messages (see the Design section for more information).
As before the provided server requires the port on the command line.
java connectfour.server.ConnectFourServer port
java connectfour.gui.ConnectFourGUI host port
A class diagram including the public state/methods is being provided to you here. Note this does not include any private state or methods that you may need to write on your own.
Javadocs for the provided source code is provided to you here: https://www.cs.rit.edu/~csci142/Labs/08/doc/.
You should not edit any class files besides ConnectFourGUI.java, but you are free to add other source code to the connectfour.gui package.
Only 10% of your grade is based on the design this time, since
it is largely given to you. Nevertheless, here are some rules you
should follow to get the design points.
updatemessage from the model.
Platform.runLaterin your GUI view to keep things running correctly. An example that demonstrates this can be found here.
javafxpackage. Beware, because your development tool may erroneously suggest a class with the same name from the
The provided plain-text user interface (PTUI) inherits a
home-grown class that was designed to be used similarly to how
is used within a JavaFX program. But be careful; there are
You have complete freedom in how you implement your GUI, as long as it functions correctly. You do not need to create a grid of buttons like the instructor solution unless you want to. A row of buttons at the top for dropping the pieces is sufficient, and you can use the remainder as a grid to draw the pieces into. Just make sure that when it is not this players turn to move that the buttons remain inactive.
There are many examples posted in the week's lecture area on the web site. If you look at them you may get insights as to how to implement things.
Use the discussion topic in MyCourses! Remember that it's OK to post a few lines of code, either to get help, or to provide help to others.
You should zip up your src directory into a file named lab8.zip.
and submit it to the dropbox on MyCourses by the due date.
Do not use absolute file path names in your code!
They do not port. Instead, look at using the
class and the
method in class