Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CONNECT FOUR JAVA FILE /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools

image text in transcribedimage text in transcribedimage text in transcribed

CONNECT FOUR JAVA FILE

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates * and open the template in the editor. */ package connectfour;

import java.util.Scanner;

/** * * @author yordanosmogos */ public class ConnectFour { public static void main (String[] args) { // DON'T MODIFY THE MAIN METHOD UNLESS FOR DEBUGGING //MAKE SURE YOU GET RID OF YOUR MODIFICATIONS HERE BEFORE SUBMISSION

String[][] board = createEmptyBoard();

Scanner input = new Scanner(System.in);

boolean bl = true;

printPattern(board);

while(bl) { int player1 = 1 , player2 = 2 , userInput; System.out.println("Please drop a RED disk at the column between 0 and 6:"); userInput = input.nextInt(); dropDisk(board, userInput , player1); printPattern(board); System.out.println("Please drop a YELLOW disk at the column between 0 and 6:"); userInput = input.nextInt(); dropDisk(board, userInput , player2); printPattern(board);

String win = checkWinner(board); /* Write code to announce if there is winner and end the game */

} // end of while loop

} // end of main public static String[][] createEmptyBoard() { /* This method prints the first empty pattern for the game DON'T MODIFY THIS METHOD */ String[][] f = new String[7][15]; for (int i =0;i

if (j% 2 == 0) f[i][j] ="|"; else f[i][j] = " "; if (i==6) f[i][j]= "-"; } } return f; } // end of createEmptyBoard public static void printPattern(String[][] brd) { //Write your code here to print an updated pattern } // end of printPattern public static void dropDisk(String[][] brd, int positin, int player) { /*Write your code to drop the disk at the position the user entered depending on which player*/ } // end of dropDisk public static String checkWinner(String[][] brd) { /*Write your code to check if there is a winner. If there is, then return the charaster of the winners color( withe R or Y) */ String str = " "; return str; } // end of checkWinner } // end of class

CSC210 Assignment 4 (Due Sunday 05/06/2018 at 11:59pm) GAME CONNECT FOUR Title: Game Connect Four A. Program Description Connect four is a two-player game in which the players alternately drop colored disks into a seven column, six row vertically suspended grid as shown below: The objective of the game is to connect four same-colored disks in a row, a column or a diagonal before your opponent can do otherwise The program prompts two players to drop a yellow or red disk alternately. Whenever a disk is dropped, the program redisplays the board on the console and determines the status of the game (win, draw or continue). Here is a sample run

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

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions