Question

Write a JavaFX application program to play an interactive version of Tic-Tac-Toe

Write a JavaFX application program to play an interactive version of Tic-Tac-Toe

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import javafx.application.Application;

import javafx.scen.Parent;

import javafx.scence.Scene;

import javafx.scene.layout.Pane;

import javafx.stage.Stage;

public class TicTacToegame extends Application

{

private Parent gamedetails{

Pane p1=new Pane();

String tiles[3][3];

p1.setPrefsize(700,700);

for(int i=0;i<3;i++)

{

for(int j=0.j<3;j++)

{

Tile t1=new Tile();

}

}

p1.getchildren.add(t1);

}

public void start(Stage stage1)

{

Scene s1=new Scene;

stage1.setScene(s1.gamedetails());

stage1.show();

}

public class Tile extends Pane{

public Tile()

{

Text t1=new Text();

public String X()

{

t1.setText("X");

return true;

}

public String Y()

{

t1.setText("O");

return true;

}

setOnMouseClicked(event->{

if(event.getButton()==MouseButton.PRIMARY)

X();

else

if(event.getButton()==MouseButton.SECONDARY)

Y();

}

public void LogicOfGame(){

Text t2=new Text();

public Winner()

{

t2.setText(10,20,"You win");

return;

}

for(i=0;i<3;i++)

{

for(j=0;j<3;j++)

{

if(tiles[i][j].getvalue.equals(tiles[i][j+1].getvalue)&&tiles[i][j].getvalue.equals(tiles[i][j+2])

Winner();

else

if((tiles[i][j].getvalue.equals(tiles[i+1][j+1])&&t(tiles[i][j].getvalue.equals(tiles[i+2][j+2]))

Winner();

else

if(tiles[i][j].getvalue.equals(tiles[i+1][j].getvalue)&&tiles[i][j].getvalue.equals(tiles[i+2][j])

else

if((tiles[i][j].getvalue.equals(tiles[i+1][j+1])&&t(tiles[i][j].getvalue.equals(tiles[i+2][j+2]))

Winner();

}

}

public static void main(String args[]){

launch(args[]);

}

Add a comment
Know the answer?
Add Answer to:
Write a JavaFX application program to play an interactive version of Tic-Tac-Toe
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT