forked from carlosmrno/Predator_Prey
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.java
More file actions
86 lines (70 loc) · 2.04 KB
/
Copy pathController.java
File metadata and controls
86 lines (70 loc) · 2.04 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
package sample;
import com.sun.tools.javac.comp.Enter;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.net.URL;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ResourceBundle;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.KeyCode;
public class Controller implements Initializable
{
@FXML
private Label PredatorLabel;
@FXML
private Label PreyLabel;
@FXML
private Label GridRowLabel;
@FXML
private Label GridColumnLabel;
@FXML
private Label TimeStepsLabel;
@FXML
private TextField predatorTextBox;
@FXML
private TextField preyTextBox;
@FXML
private TextField gridRowTextBox;
@FXML
private TextField gridColumnTextBox;
@FXML
private TextField timeTextBox;
@FXML
private Button SimulateButton;
@FXML
private Button PositionsButton;
@Override
public void initialize(URL location, ResourceBundle resources)
{
PositionsButton.setOnAction(e->System.out.println("You pressed me!"));
SimulateButton.setOnAction(e-> {
getTextfromPredatorBox();
getTextfromPreyBox();
});
}
public void getTextfromPredatorBox()
{
String input2 = predatorTextBox.getText();
System.out.println("Predators: " + input2);
Predator pred = new Predator();
int num = Integer.parseInt(input2); // Converts a STRING -> INTEGER
pred.setNum_of_Preds(num);
System.out.println("Number of predators: " + pred.getNum_of_Preds());
}
public void getTextfromPreyBox()
{
String input = preyTextBox.getText();
Prey prey = new Prey();
int num = Integer.parseInt(input);
prey.setNum_of_Prey(num);
System.out.println("Prey: " + prey.getNum_of_Prey());
}
}