-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfirmPressed.java
75 lines (64 loc) · 1.67 KB
/
ConfirmPressed.java
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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ConfirmPressed implements ActionListener
{
private String[] p1 = new String[2];
private String[] p2 = new String[2];
private int boardSize;
private GameSettingGUI setting;
private GameControl control;
// constructor that initializes the strings and boardSize
public ConfirmPressed()
{
p1[0] = "N/A";
p2[0] = "N/A";
boardSize = 8;
}
// when confirm is pressed this is called
public void actionPerformed(ActionEvent event)
{
String[] names = setting.getPlayerName();
String[] color = setting.getPlayerColor();
p1[0] = names[0];
p1[1] = color[1];
p2[0] = names[1];
p2[1] = color[1];
boardSize = setting.getBoardSize();
Player[] players = this.getPlayer();
if (!(names[0].equals("") || names[1].equals("")) && setting.confirmFlag())
{
control.setPlayer(players);
control.reset(boardSize);
setting.closeWindow();
}
}
// sets the gameSettingGUI
public void setGameSettingGUI(GameSettingGUI s)
{
this.setting = s;
}
// returns the gameSettingGUI
public GameSettingGUI getGameSettingGUI()
{
return this.setting;
}
// returns a list of with the player names entered
public Player[] getPlayer()
{
Player[] players = new Player[2];
players[0] = new Player(p1[0], p1[1], 0 , 0);
players[1] = new Player(p2[0], p2[1], 0 , 0);
return players;
}
// returns the boardSize
public int getBoardSize()
{
return boardSize;
}
// sets the control
public void setControl(GameControl c)
{
control = c;
}
}