So I am working on my first project- however, the compiled program 'skips' on some of the code I wrote because of the way I used the scope in it (I figured). Anyways, I will supply the code below.
import java.util.Random; public class TicTacToe { public static void main(String[] args){ Random placement = new Random(); int placement1 = placement.nextInt(3); if (placement1 == 1){ for(int i = 0 ; i < 10000 ; i++){ int placementi = placement.nextInt(3); if (placementi != 1 ){ break; } else{ placement1++; } } } else { if(ticTacToe[0][placement1] == 1){ for(int i = 0 ; i < 10000 ; i++){ int placementx = placement.nextInt(3); if (placementx != 1 && placementx != placement1){ break; } else{ placement1++; } } ticTacToe[0][placement1] = 2; System.out.println(placement1); for(int i = 0 ; i < 3 ; i++){ for(int j = 0 ; j < 3; j++) { System.out.print(ticTacToe[i][j] + " " ); } System.out.println(); } } } } }
obviously, this is probably not the best way to execute this code however I am aiming to improve so giving your opinion can be helpful.
https://stackoverflow.com/questions/67030044/how-do-i-correctly-use-scopes April 10, 2021 at 09:36AM
没有评论:
发表评论