Menu

[solved]-Assignment 2 Assignment Asked Following 1 Using Uml Tool Choice Design Class Diagram Neces Q39062190

Assignment 2

For this assignment you are asked to do the following:

1. Using a UML tool of your choice, design the Class diagramnecessary to capture these classes, methods and attributes. [10pts]

2. Use a tool of your choice (e.g. Visual Paradigm free editionor any other UML tool) to use Forward Engineering in order tocreate the java class files (i.e. in Forward engineering the toolcan automatically generate java files directly from the classdiagrams, which is why it is a good idea to spend extra time ondoing the design right). [10 pts]

3. Question: What is Reverse Engineering? can you find a toolthat can perform reverse engineering? Can you reverse engineeringthe java code that you created in (2) above and regenerate theclass diagrams back from the code? Describe the steps you aretaking and what results you get (note that you may not get a fullround-trip here meaning your generated class diagrams may not beexactly the diagrams you started with because that depends on thequality of the tool). [10 pts]

Consider the game of Tic-Tac-Toe.

Here are some basic ideas for designing the game:

block.java a block represents a playable celland maintains a state attribute that is either EMPTY, occupied byX, or occupied by O) . By default it is EMPTY, would requiresetState, getState, and a toString where EMPTY is just a blankspace.

board.java a board has or contains 9 blocksin a 2D array (3×3) that shapes the game space of tic-tac-toe. Italso maintains an internal state which can be one of the following:EMPTY (the initial state of the board), X (X claims a win), Y (Yclaims a win), or DRAW (where neither X nor Y can claim a win andno further moves are possible). The board has the key methodsmakeMove( ) that is called by a player making a move and getState()or updateState() that updates the state of the board after everymove. It checks for a win or a draw when they occur. Note that theboard instantiates and maintains all the blocks.

game.java contains a game board and twoplayers, playerX and playerO. It manages the iteration with theplayers. First by getting the player names, does a coin toss todecide the turn and allows each player to take a turn and make amove. It finally announces the winner/draw when the game ends.

player.java is an abstractclass that maintains a design that every player has a symbol (X orO), a name, and an abstract play(board gameboard) method. It alsomaintains a reference to the game board for players to examine andmake their move.

HumanPlayer.java extends player, a type ofplayer that requests its input from the user and submit the move(or play) to the gameboard.

AIPlayer.java extends player, a type ofplayer that implements a simple computer player. The simpleststrategy is to play a valid random move. Feel free to design moredifficult or “intelligent” game players.

TicTacToe.java a simple wrapper class formain, here is its contents:

class TicTacToe {

public static void main(String args[]) {

game myGame = new game();

myGame.start();

}

}

global.java this is a global interface thatis implemented by any class to maintain some shared constants.

Expert Answer


Answer to Assignment 2 For this assignment you are asked to do the following: 1. Using a UML tool of your choice, design the Class… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *