In this project we will implement an interactive game server running on the Internet.
And will include a server side and a client side with a graphical interface.
The entire project will be written in the Java language.
The server will have several game options and will allow you to play several games simultaneously, on the same computer or from a number of different computers.
We will play two games: "Tic Tac Toe" and "Catch the Bunny".
Both games are designed for a single player against the computer.
Our server will be built so you can easily add more games if we wanted to.
The Project Classes are located in this document, and do not modify signatures of functions.
The definitions and interfaces should be same as in the API.
In this section we will implement the two games and the logic of each of them.
Rules of the game TicTacToe
Rules of the game Catch the Bunny
Rules for the joint realization of both games
As mentioned in the introduction, we want to implement the server so that more games can be easily added.
In order to fulfill this requirement, we will use the "Strategy Pattern" method: we will define an interface through which the games can be played. A department that will manage a game will maintain a reference to this interface and use it, but will not recognize his various implements (the actual realizing classes, which are called Concrete Classes).
The departments that will realize both games will realize this by implementing the interface (they will contain functionality similar, with the same usage).
Also, this will allow us to easily hold one game by choice and replace when needed.
Interface that we define will be called IgameAlgo, and it will contain the following methods, which will allow to manage the game from start to finish:
The above interface will be implemented as an abstract class called GAMEBoard. It serves as a common denominator between all games available in the software.
For each game, we define an abstract class: CatchTheBunny and TicTacTow. These classes will implement the Tic Tac Toe and Catch the Bunny respectively.
They will implement all the methods defined in the interface IgameAlgo Except for the method calcComputerMove.
For each of the classes CatchTheBunny and TicTacTow we will define two classes that inherit from them, which will each perform the method calcComputerMove according to the chosen algorithm.
Classes CatchTheBunnyRandom and TicTacTowGameRandom will implant random selection in the Tic-Tac-Toe game and Catch the Bunny, respectively, as described above.
The classes CatchTheBunnySmart and TicTacTowGameSmart will implant an logical choice in Tic-Tac-Toe and Catch the Bunny, respectively, as described above.
Note, that in these classes, since the algorithm definition is part of the task, it is highly recommended to document the code so that whoever reads it can understand what you mean.
The last two Classes that we will implement in this section are test departments.
There is great value for unit testing during the development process, even before that we are interfacing with another part of the software or handing over the software.
Implement two classes with the help of Junit framework: CatchTheBunnyTest and TicTacTowTest
Each class will check the two algorithms of its game and will contain a method @test for each of the computer game algorithms.
Finally, pack all 10 Classes described in packages In the structure (pay attention to the structure of the folders) and the following names: see image.