Question: UML Class Diagram for Tic - Tac - Toe System 1 . Model Class Attributes: private Marker [ ] [ ] gameBoard private Marker currentTurn

UML Class Diagram for Tic-Tac-Toe System
1. Model Class
Attributes:
private Marker[][] gameBoard
private Marker currentTurn
private Marker winner
Methods:
public Model()
public void setState(int x, int y) throws GameOverException, IllegalMarkerPlacementException
private void detectWinner()
public Marker[][] getGameBoard()
public Marker getCurrentTurn()
public Marker getWinner()
public void resetModel()
2. Marker Enum
Constants:
NONE
X
O
3. IllegalMarkerPlacementException Class
Constructors:
public IllegalMarkerPlacementException()
public IllegalMarkerPlacementException(String message)
4. GameOverException Class
Constructors:
public GameOverException()
public GameOverException(String message)
5. View Class (extends JFrame, implements Observer)
Attributes:
private JButton[][] buttons
private JLabel winLabel
private JLabel currentTurnLabel
private JButton resetGameButton
Methods:
public View()
public void update(Observable o, Object arg)
public void assignButtonListener(int x, int y, ActionListener l)
public void assignResetButtonListener(ActionListener l)
6. Controller Class
Attributes:
private Model model
private View view
Methods:
public Controller(Model m, View v)
public void makeMove(int x, int y)
public void resetGame()
7. ButtonClickListener Class (implements ActionListener)
Attributes:
private int x
private int y
private Controller controller
Methods:
public ButtonClickListener(int x, int y, Controller c)
public void actionPerformed(ActionEvent e)
8. ResetGameListener Class (implements ActionListener)
Attributes:
private Controller controller
Methods:
public ResetGameListener(Controller controller)
public void actionPerformed(ActionEvent e)
9. TicTacToeDemo Class
Methods:
public static void main(String[] 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!