Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help please with Java UML Diagrams I need help with UML Diagrams for each of these methods preferably using draw.io Each method must have a

Help please with Java UML Diagrams

I need help with UML Diagrams for each of these methods preferably using draw.io

Each method must have a separate UML diagram

GameBoard.java This class will represent the game board itself. All attributes of the class must be private unless they are static AND final. Your game board should be a 2-dimensional array of characters where position [0][0] would be the bottom left of the board and [8][6] would be the top right of the board. Each position will have a single blank space character (' ') until a player plays on that position. At that point, the character will change to either X or O to represent that player. A constructor with no parameters should be included. This class cannot interact with the users by asking for input or printing output to the screen. The following methods must be publicly available. Also include a constructor with no parameters. They must have the exact names, parameters, and return types listed. I have provided contracts for some, but not all of the methods. You must include the provided contracts as well as write contracts for the remaining methods. You must provide Javadoc comments for each method. public boolean checkIfFree(int c) { //returns true if the column can accept another token; false otherwise. } public void placeToken(char p, int c) { //places the character p in column c. The token will be placed in the lowest available row in column c. }

public boolean checkForWin(int c) { //this function will check to see if the last token placed in column c resulted in the player winning the game. If so it will return true, otherwise false. //Note: this is not checking the entire board for a win, it is just checking if the last token placed results in a win. //You may call other methods to complete this method } public boolean checkTie() { //this function will check to see if the game has resulted in a tie. A game is tied if there are no free board positions remaining. You do not need to check for any potential wins because we can assume that the players were checking for win conditions as they played the game. It will return true if the game is tied and false otherwise. } public boolean checkHorizWin(BoardPosition pos, char p) { //checks to see if the last token placed (which was placed in position pos by player p) resulted in 5 in a row horizontally. Returns true if it does, otherwise false } public boolean checkVertWin(BoardPosition pos, char p) { //checks to see if the last token placed (which was placed in position pos by player p) resulted in 5 in a row vertically. Returns true if it does, otherwise false } public boolean checkDiagWin(BoardPosition pos, char p) { //checks to see if the last token placed (which was placed in position pos by player p) resulted in 5 in a row diagonally. Returns true if it does, otherwise false //Note: there are two diagonals to check } public char whatsAtPos(BoardPosition pos) { //returns what is in the GameBoard at position pos //If no marker is there, it returns a blank space char. }

public boolean isPlayerAtPos(BoardPosition pos, char player) { //returns true if the player is at pos; otherwise, it returns false //Note: this method will be implemented very similarly to whatsAtPos, but it's asking a different question. We only know they will be similar because we know GameBoard will contain a 2D array. If the data structure were to change in the future, these two methods could be radically different. }

public String toString() {}

Additionally, you must override the toString() method inherited from the Object class. This will return one string that shows the entire game board. You will then be able to call it in your GameScreen.java file to print it to the screen. It should be formatted as follows: |0|1|2|3|4|5|6| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |X| | | | | |X| |O| |

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

What are bar codes and how are they used in labor costing?

Answered: 1 week ago

Question

6. Explain the power of labels.

Answered: 1 week ago

Question

10. Discuss the complexities of language policies.

Answered: 1 week ago