Wednesday, February 8, 2017

Code to run the game

/**
*[TTTGame3D]
*NAME:       [Gunarath A. M. Raveen]
*Assignment: []
*QUESTION:   []
*
*PURPOSE:    [Main method that will run the game]
*/
import java.util.Scanner;
public class TTTGame3D {
  private static int WINDOW_SIZE = 700;
  
//Main method that will initialize the board size and start the game.
  public static void main(String[] args) {
    int n = getBoardSize();
    TTT3DWindow theWindow = new TTT3DWindow(WINDOW_SIZE,WINDOW_SIZE,n);
  }

//To ask the from user the board size untill it is larger than or equal 3 and less than and equal to 6 return the
  //size of the board. If it is not display the message indicating a invalid move
  public static int getBoardSize(){
    int n = 0;
    Scanner keyboard = new Scanner(System.in);
    do {
      System.out.println("Enter the board size: " );
      n = keyboard.nextInt();
      if (n >=3 && n<=6)
        return n;
      else
        System.out.println("Invalid Size " );
    }while (n!=0);
    return n;
  }
 
 
}

No comments:

Post a Comment