Question

I need help creating a class diagram for this please:

Instructions This assignment has to be completed by each student individually. NO COLLABORATION IS ALLOWED Submit YourASURite

Connect4 Game Connect4 is a 2-player turn-based game played ori a vertical board that has seven hollow columns and six rows.

Create a simple console-based Ul as shown in the figures below Begin Game. PlayerX-your turn. Choose a column number fromm 1-

When the game starts, indicate that it is PlayerXs turn. Ask the player to choase colunn number from 1-7 Check if the move i

I am not sure what more you want? it has 2 classes at least Connect4 and Connect4TextConsole.

Instructions This assignment has to be completed by each student individually. NO COLLABORATION IS ALLOWED Submit YourASURitelD ProjectDeliverable2.zip compressed folder should contain the following files following This the 1. 2. Connect4.java 〔Game Logic Module) Connect4TextConsole.java (Console-based Ul to test the gamel 3. JavaDoc documentation files index.html and all other supporting files such as.cs5 and .js files generated by the tool). Submit the entire folder Completed TimeLag, Design form, DefectLog, and ProjectSummary pravided at the end af this assignm A few screen shots showing test results af your working game and answers to reflection docurment Readme file (optional: submit if you have any special instructions for testing) 4. ent description 5. questions written inline in this 6. Connect4 Game Connect4 is a 2-player turn-based game played orn a vertical board that has seven hollow columns and slx rows. Each column has a hole in the upper part of the board, where pieces are introduced. There is a window for every square, so that pieces can be seen from both sides, In short, it's a vertical board with 42 windows distributed in 6 rows and 7 columns. Both players have a set of 21 thin pieces (like coins]; each of them uses a different color
Connect4 Game Connect4 is a 2-player turn-based game played ori a vertical board that has seven hollow columns and six rows. Each column has a hole in the upper part of the board, where pieces are introduced. There is a window for every square, so that pieces can be seen from both sides. In short, it's a vertical board with 42 windows distributed in 6 rows and T columns. Both players have a set of 21 thin pieces like coins]; each of them uses a different color The board is empty at the start of the game. The aim for both players is ta make a straight line ot four own pieces; the line can be vertical, horizontal ar diagonal. Reference Program Requirements: Implement a Java-based Cannect4 game to be hasted in the ARENA Game system in the future In this first version build it as a simple console-based game played by 2 players Player X and Player O. Ensure that following: Make use of good Object-Oriented design Provide documentation using Javadoc and appropriate comments in your code Generate HTML documentation using Javadoc tool Create 2 packages core and ui. » Create a separate class for the game loglc called Connect4.java and place it in core package Create a separate class for the text-based Ul called Connect4TextConsole.java and place it in ui package Create a simnle ronsola-hased
Create a simple console-based Ul as shown in the figures below Begin Game. PlayerX-your turn. Choose a column number fromm 1-7 PlayerOyour turn. Choose a colurm from 1-7 number ol I IXI 11 IIIIojx I I I IoloxIXI II I IolxIXIXI ol I xIXolol Player X Won the Game
When the game starts, indicate that it is PlayerX's turn. Ask the player to choase colunn number from 1-7 Check if the move is valid. If valid move, then show the state of the grid by placing an X at the botta column. Next check for "WIN" state i.e., if playerX has an X in four consecutive horizontal vertical, or diagonal oells of the grid). If it is a "WIN state i and close the game. If not continue the game m-most empty row of the specified inform that PlayerX is the winner * Indicate that it is PlayerO's turn. Ask the player to choose column number from 1-7, Continue the game till one of them wins or game results in a draw Personal Process: Follow a good personal process for implementing this game. Please use the time log Iprovided at the end af this document) to keep trark af time spent in each phase of development. Please use the defect log(provided at the end af this document) to keep trark af defects found and fixed in each phase af . opment. When you are done implementing and testing your program, complete the Project Summary form to summarize your eff and defects. Also answer the reflection questions listed below in Post-morterm phasc. ort Follow these steps in developing this game: 1. Plan-understand the program specification and get any clarifications needed
0 0
Add a comment Improve this question Transcribed image text
Answer #1

thanks for the question, I have designed 90% of the class, you just need to implement the winner method() in the Connect4 class, everything else is fully implemented.

==========================================================================================

public class Connect4 {

    private char[][] board;
    private int turn;

    public Connect4() {
        board = new char[6][7];
        for (int r = 0; r < 6; r++) {
            for (int c = 0; c < 7; c++) {
                board[r][c] = ' ';
            }
        }
        turn = 0;
    }

    public boolean insert(int column, char letter) {
        if (1 <= column && column <= 7) {

            for (int row = 5; row >= 0; row--) {
                if (board[row][column - 1] == ' ') {
                    board[row][column - 1] = letter;
                    turn += 1;
                    return true;
                }
            }
            System.out.println("There is no more room in that column");


        } else {
            System.out.println("Invalid column entered");
        }

        return false;
    }

    public void displayBoard() {

        for (int row = 0; row < 6; row++) {
            for (int col = 0; col < 7; col++) {
                System.out.print("|" + board[row][col] + "");
            }
            System.out.println("|");
        }
    }

    public boolean isWinner() {
        // need to implement
        return turn == 42;
    }
}

=========================================================================================

import java.util.Scanner;

public class Connect4TextConsole {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        Connect4 connect4 = new Connect4();
        connect4.displayBoard();
        System.out.println("Begin Game");
        int turn = 0;
        while (!connect4.isWinner()) {
            if (turn++ % 2 == 0) {
                while (true) {
                    System.out.print("PlayerX - your turn. Choose a column number from 1-7: ");
                    int column = scanner.nextInt();
                    boolean valid = connect4.insert(column, 'X');
                    if (valid) {
                        break;
                    }
                }
            }else{

                while (true) {
                    System.out.print("PlayerY - your turn. Choose a column number from 1-7: ");
                    int column = scanner.nextInt();
                    boolean valid = connect4.insert(column, 'Y');
                    if (valid) {
                        break;
                    }
                }
            }
            connect4.displayBoard();
        }
    }
}

==========================================================================================

Run: Connect4TextConsole Playern-your turn. しnoose a column number 1rom 1-72 Invalid column entered PlayerX - your turn. Choo

Add a comment
Know the answer?
Add Answer to:
Instructions This assignment has to be completed by each student individually. NO COLLABORATION I...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The game Battleship is played on a grid board. Each opponent has multiple ships that are...

    The game Battleship is played on a grid board. Each opponent has multiple ships that are placed on the grid where the other opponent cannot see them. In order to attack, each player takes turns calling out coordinates on a grid. If the attacker calls out a coordinate that hits their opponent's ship, they must call out, "Hit." You are going to be developing a computer program to mimic this game. Use the Gridlayout that is six columns by six...

  • The game Battleship is played on a grid board. Each opponent has multiple ships that are placed on the grid where the o...

    The game Battleship is played on a grid board. Each opponent has multiple ships that are placed on the grid where the other opponent cannot see them. In order to attack, each player takes turns calling out coordinates on a grid. If the attacker calls out a coordinate that hits their opponent's ship, they must call out, "Hit." You are going to be developing a computer program to mimic this game. Use the Gridlayout that is six columns by six...

  • Connect 4 is a 2 player game where each player has a set of colored tokens...

    Connect 4 is a 2 player game where each player has a set of colored tokens (red or yellow). Players take turns during which they place a single token into one of the columns of an n by m grid (where n is the number of rows and m is the number of columns. They place their token into a slot at the top of the column and it falls into the lowest unoccupied slot in that column. A player...

  • JAVA Only Help on the sections that say Student provide code. The student Provide code has...

    JAVA Only Help on the sections that say Student provide code. The student Provide code has comments that i put to state what i need help with. import java.util.Scanner; public class TicTacToe {     private final int BOARDSIZE = 3; // size of the board     private enum Status { WIN, DRAW, CONTINUE }; // game states     private char[][] board; // board representation     private boolean firstPlayer; // whether it's player 1's move     private boolean gameOver; // whether...

  • Use Java language to create this program Write a program that allows two players to play...

    Use Java language to create this program Write a program that allows two players to play a game of tic-tac-toe. Using a two-dimensional array with three rows and three columns as the game board. Each element of the array should be initialized with a number from 1 - 9 (like below): 1 2 3 4 5 6 7 8 9 The program should run a loop that Displays the contents of the board array allows player 1 to select the...

  • Please help me write a Pseudocode (please do NOT answer in JAVA or Python - I...

    Please help me write a Pseudocode (please do NOT answer in JAVA or Python - I will not be able to use those). Please ALSO create a flowchart using Flowgarithm program. Thank you so much, if answer is provided in Pseudocode and Flowchart, I will provide good feedback and thumbs up to the resonder. Thank you! Tic-Tac-Toe Game Write a program that allows two players to play a game of tic-tac-toe. Use a two- dimensional char array with three rows...

  • I need help with my programming assignment. The language used should be java and the algorithm...

    I need help with my programming assignment. The language used should be java and the algorithm should use search trees so that you play against the computer and he chooses the best move. The tree should have all possibilities on the leaves and you could use recursion to so that it populates itself. The game can be a 3*3 board (no need the make it n*n). Please put comments so that I can understand it. Thanks The game of ‘Walls’...

  • Hello I am having trouble with a connectFour java program. this issue is in my findLocalWinner...

    Hello I am having trouble with a connectFour java program. this issue is in my findLocalWinner method, it declares a winner for horizontal wins, but not for vertical. if anyone can see what im doing wrong. public class ConnectFour { /** Number of columns on the board. */ public static final int COLUMNS = 7; /** Number of rows on the board. */ public static final int ROWS = 6; /** Character for computer player's pieces */ public static final...

  • Tic-Tac-Toe Game Write a program that allows two players to play a game of tic-tac-toe. Use...

    Tic-Tac-Toe Game Write a program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that does the following: Displays the contents of the board array. Allows player 1 to select a location on the board for an X. The program should ask the user to enter...

  • (C++) Please create a tic tac toe game. Must write a Player class to store each...

    (C++) Please create a tic tac toe game. Must write a Player class to store each players’ information (name and score) and to update their information (increase their score if appropriate) and to retrieve their information (name and score).The players must be called by name during the game. The turns alternate starting with player 1 in the first move of round 1. Whoever plays last in a round will play second in the next round (assuming there is one).The rows...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT