-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwiningGame.java
More file actions
104 lines (79 loc) · 4.09 KB
/
winingGame.java
File metadata and controls
104 lines (79 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class winingGame {
//frame for dialog box (Wining or no one wins)
private JFrame frame;
int z=0;
//getting parameters from GameGui class
public winingGame (JLabel xCount,JLabel oCount,int xCount1,int oCount1,int i,int b1,int b2,int b3,int b4,int b5,int b6, int b7, int b8, int b9) {
//if else state used to implement different condition for win and and tied game
if(b1==1 && b2==1 && b3==1) {
//xPlayer wins if b1,b2,b3 are equal to 1 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player x Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b4==1 && b5==1 && b6==1) {
//xPlayer wins if b4,b5,b6 are equal to 1 and shows the dialog box
JOptionPane.showMessageDialog(frame, "Player x Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b7==1 && b8==1 && b9==1) {
//xPlayer wins if b7,b8,b9 are equal to 1 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player x Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b1==1 && b4==1 && b7==1) {
//xPlayer wins if b1,b4,b7 are equal to 1 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player x Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b2==1 && b5==1 && b8==1) {
//xPlayer wins if b2,b5,b8 are equal to 1 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player x Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b9==1 && b3==1 && b6==1) {
//xPlayer wins if b3,b6,b9 are equal to 1 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player x Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b1==1 && b5==1 && b9==1) {
//xPlayer wins if b1,b5,b9 are equal to 1 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player x Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b3==1 && b5==1 && b7==1) {
//xPlayer wins if b3,b5,b7 are equal to 1 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player x Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(i==9) {
//if i values becomes 9 than no one wins
JOptionPane.showMessageDialog(frame, "No One Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
} else if(b1==0 && b2==0 && b3==0) {
//oPlayer wins if b1,b2,b3 are equal to 0 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b4==0 && b5==0 && b6==0) {
//oPlayer wins if b4,b5,b6 are equal to 0 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b7==0 && b8==0 && b9==0) {
//oPlayer wins if b7,b8,b9 are equal to 0 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b1==0 && b4==0 && b7==0) {
//oPlayer wins if b1,b4,b7 are equal to 0 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b2==0 && b5==0 && b8==0) {
//oPlayer wins if b2,b5,b8 are equal to 0 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b9==0 && b3==0 && b6==0) {
//oPlayer wins if b9,b3,b6 are equal to 0 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b1==0 && b5==0 && b9==0) {
//oPlayer wins if b1,b5,b9 are equal to 0 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
else if(b3==0 && b5==0 && b7==0) {
//oPlayer wins if b3,b5,b7 are equal to 0 and show the dialog box
JOptionPane.showMessageDialog(frame, "Player O Wins", "Tic Tac Toe",JOptionPane.INFORMATION_MESSAGE);
}
}
}