Class TwoDArraysMain

Object
TwoDArraysMain

public class TwoDArraysMain extends Object
The driver class for this app.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static int[][]
    Our Connect4 board, which has 6 rows and 7 columns.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Method that contains a loop to run until victory is achieved or until a player desires to exit the game.
    static void
    main(String[] args)
    The main function to begin program execution.
    static boolean
    playerChoice(int player, Scanner scnr, int[][] board, TwoDArraysUtility util)
    This method is where the player chooses the column to play their piece in, it also checks that the input it 1-7 and if input is 0, the game is exited.
    static void
    This method prints the entire board 2D Array and some additional lines below for added readability.
    static void
    This method sets the entire board to 0 values.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • board

      static int[][] board
      Our Connect4 board, which has 6 rows and 7 columns.
  • Constructor Details

    • TwoDArraysMain

      public TwoDArraysMain()
  • Method Details

    • main

      public static void main(String[] args)
      The main function to begin program execution.
      Parameters:
      args -
    • gameLoop

      public static void gameLoop()
      Method that contains a loop to run until victory is achieved or until a player desires to exit the game.
    • setBoard

      public static void setBoard()
      This method sets the entire board to 0 values.
    • printBoard

      public static void printBoard()
      This method prints the entire board 2D Array and some additional lines below for added readability.
    • playerChoice

      public static boolean playerChoice(int player, Scanner scnr, int[][] board, TwoDArraysUtility util)
      This method is where the player chooses the column to play their piece in, it also checks that the input it 1-7 and if input is 0, the game is exited.
      Parameters:
      player -
      scnr -
      board -
      util -
      Returns: