Skip to content

Commit 5f2defd

Browse files
authored
Merge pull request #4 from 7oSkaaa/master
Master
2 parents a7855c9 + 68214c3 commit 5f2defd

File tree

10 files changed

+262
-78
lines changed

10 files changed

+262
-78
lines changed
60 Bytes
Binary file not shown.
-12 Bytes
Binary file not shown.
237 Bytes
Binary file not shown.
Binary file not shown.

src/Again/again_ind.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ public class again_ind extends JFrame implements ActionListener {
1111
JFrame frame;
1212
JButton yes, no;
1313
JLabel text_field;
14+
boolean is_Hard;
1415

15-
public again_ind(){
16+
public again_ind(boolean is_Hard){
1617
yes = new JButton("Yes");
1718
no = new JButton("No");
19+
this.is_Hard = is_Hard;
1820
text_field = new JLabel("Do you want to play again ?");
1921
frame = new JFrame("Tic Tac Toe");
2022
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@@ -46,7 +48,7 @@ public void actionPerformed(ActionEvent e) {
4648
window.dispose();
4749
}
4850
if(e.getSource() == yes){
49-
new Tic_Tac_Toe_Individual();
51+
new Tic_Tac_Toe_Individual(is_Hard);
5052
}else {
5153
new choose();
5254
}

src/Choose/choose.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.awt.event.ActionListener;
66
import java.util.Objects;
77
import Input.input;
8-
import individual.*;
8+
import ind_choose.*;
99

1010
public class choose extends JFrame implements ActionListener {
1111

@@ -48,7 +48,7 @@ public void actionPerformed(ActionEvent e) {
4848
new input();
4949
frame.dispose();
5050
}else if(e.getSource() == individual){
51-
new Tic_Tac_Toe_Individual();
51+
new Ind_choose();
5252
frame.dispose();
5353
}else if(e.getSource() == quit){
5454
System.exit(0);

src/Input/input.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package Input;
22
import javax.swing.*;
3+
import javax.swing.plaf.basic.BasicBorders;
34
import java.awt.*;
45
import java.awt.event.ActionEvent;
56
import java.awt.event.ActionListener;
@@ -38,6 +39,10 @@ public input(){
3839
logo.setBounds(320, 75, 150, 150);
3940
user1.setFont(new Font("MV Boli", Font.PLAIN, 20));
4041
user2.setFont(new Font("MV Boli", Font.PLAIN, 20));
42+
name1.setFont(new Font("MV Boli", Font.PLAIN, 20));
43+
name2.setFont(new Font("MV Boli", Font.PLAIN, 20));
44+
name1.setMargin(new Insets(2, 4, 2, 2));
45+
name2.setMargin(new Insets(2, 4, 2, 2));
4146
user1.setForeground(Color.RED);
4247
user2.setForeground(Color.BLUE);
4348
frame.add(logo);

src/ind_choose/Ind_choose.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package ind_choose;
2+
import javax.swing.*;
3+
import java.awt.*;
4+
import java.awt.event.ActionEvent;
5+
import java.awt.event.ActionListener;
6+
import java.util.Objects;
7+
import individual.*;
8+
9+
public class Ind_choose extends JFrame implements ActionListener {
10+
11+
JFrame frame;
12+
JLabel logo;
13+
ImageIcon img;
14+
JButton easy, hard, quit;
15+
16+
public Ind_choose(){
17+
frame = new JFrame("Tic Tac Toe");
18+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
19+
frame.setSize(600, 450);
20+
frame.setBackground(new Color(50, 50, 50));
21+
frame.setLayout(null);
22+
frame.setLocationRelativeTo(null);
23+
easy = new JButton("Easy");
24+
hard = new JButton("Hard");
25+
easy.setForeground(Color.BLUE);
26+
hard.setForeground(Color.RED);
27+
quit = new JButton("Quit");
28+
img = new ImageIcon(Objects.requireNonNull(getClass().getResource("ind.png")));
29+
logo = new JLabel(img);
30+
quit.addActionListener(this);
31+
easy.addActionListener(this);
32+
hard.addActionListener(this);
33+
easy.setBounds(140, 300, 150, 30);
34+
hard.setBounds(310, 300, 150, 30);
35+
quit.setBounds(225, 350, 150, 30);
36+
logo.setBounds(240, 75, 150, 150);
37+
frame.add(hard);
38+
frame.add(easy);
39+
frame.add(logo);
40+
frame.add(quit);
41+
frame.setVisible(true);
42+
}
43+
44+
@Override
45+
public void actionPerformed(ActionEvent e) {
46+
if(e.getSource() == hard){
47+
new Tic_Tac_Toe_Individual(true);
48+
frame.dispose();
49+
}else if(e.getSource() == easy){
50+
new Tic_Tac_Toe_Individual(false);
51+
frame.dispose();
52+
}else if(e.getSource() == quit){
53+
System.exit(0);
54+
}
55+
}
56+
57+
58+
}

src/ind_choose/ind.png

7.26 KB
Loading

0 commit comments

Comments
 (0)