Answered step by step
Verified Expert Solution
Link Copied!

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions