Member-only story
MVC Approach in TicTacToe implementation By Java Swing
Description:
Specification for is as follows:
● Display a 3x3 matrix of buttons.
● Each player gets a turn to pick a button which is not selected. If the player selects a button that is already selected, the system should ignore that selection and let the user select again until he/she picks a free button.
● The buttons selected by user 1 should be marked with a 1 and that for user 2 is 2.
● User 1 gets the first chance, then user 2 gets the chance and so on.
● Based on the pick, the game might continue (in which case the other player should get his/her turn) or end with either a win to the current player or a draw. When the game ends the results should be displayed in a different window
Model
TicTacToeModel.java class was created for to hold the data value .thatswhy private acess matrix 3x3 was created .
some Boolean variable were created which were used to identify to get 3 samevalue in row (up ,down ,across diagonally) ,and also identify that all matrix values are completed.
Setters and getters also was implemented for private acess variable.
Methods Created to identify to get 3 same value in row (up ,down ,across diagonally) and find all matrix index full.
So basically our model manages data and logic and rules of the our TicTacToe Game