Answered step by step
Verified Expert Solution
Question
1 Approved Answer
UML Class Diagram for Tic - Tac - Toe System 1 . Model Class Attributes: private Marker [ ] [ ] gameBoard private Marker currentTurn
UML Class Diagram for TicTacToe System
Model Class
Attributes:
private Marker gameBoard
private Marker currentTurn
private Marker winner
Methods:
public Model
public void setStateint x int y throws GameOverException, IllegalMarkerPlacementException
private void detectWinner
public Marker getGameBoard
public Marker getCurrentTurn
public Marker getWinner
public void resetModel
Marker Enum
Constants:
NONE
X
O
IllegalMarkerPlacementException Class
Constructors:
public IllegalMarkerPlacementException
public IllegalMarkerPlacementExceptionString message
GameOverException Class
Constructors:
public GameOverException
public GameOverExceptionString message
View Class extends JFrame, implements Observer
Attributes:
private JButton buttons
private JLabel winLabel
private JLabel currentTurnLabel
private JButton resetGameButton
Methods:
public View
public void updateObservable o Object arg
public void assignButtonListenerint x int y ActionListener l
public void assignResetButtonListenerActionListener l
Controller Class
Attributes:
private Model model
private View view
Methods:
public ControllerModel m View v
public void makeMoveint x int y
public void resetGame
ButtonClickListener Class implements ActionListener
Attributes:
private int x
private int y
private Controller controller
Methods:
public ButtonClickListenerint x int y Controller c
public void actionPerformedActionEvent e
ResetGameListener Class implements ActionListener
Attributes:
private Controller controller
Methods:
public ResetGameListenerController controller
public void actionPerformedActionEvent e
TicTacToeDemo Class
Methods:
public static void mainString args
Relationships
Model:
Implements Observable
View:
Extends JFrame
Implements Observer
Observes Model
Controller:
Aggregates Model and View
Uses ButtonClickListener and ResetGameListener
ButtonClickListener:
Implements ActionListener
Aggregates Controller
ResetGameListener:
Implements ActionListener
Aggregates Controller
TicTacToeDemo:
Instantiates Model, View, and Controller
Adds View as an observer to Model
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started