I am working on a project Ultimate Tic-Tac-Toe. I have made Java code which is taking input from console and giving output to the console. I want to implement the same on Web. Sample code snippet in Java looks like:
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int tour = 1;
Game g = new Game();
while (g.isEndOfGame() == 0) {
if (tour % 2 == 0) {
g.play(run());
System.out.println(g.changeToString());
} else {
int move;
do{
int bigSquare = scan.nextInt() - 1;
int smallSquare = scan.nextInt() - 1;
move = bigSquare * 9 + smallSquare;
} while (!g.contains(move));
g.play(move);
System.out.println(g.changeToString());
}
tour++;
}
}
In web, I have made 81 small blocks through HTML. How to take input on mouse click and pass to the Main class to variables bigSquare and smallSquare and similarly how to display that index in JSP?
Aucun commentaire:
Enregistrer un commentaire