-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPresentSmartSolution.java
More file actions
58 lines (48 loc) · 2.2 KB
/
PresentSmartSolution.java
File metadata and controls
58 lines (48 loc) · 2.2 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
package CryptarithmeticSolver;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
public class PresentSmartSolution {
ObservableList<String> solutionsObserverList = FXCollections.observableArrayList();
public PresentSmartSolution(SmartSolve solution, ListView solutionsListView) {
if (solution.correctSolutionsArray.size() > 0) {
for (int i = 0; i < solution.correctSolutionsArray.size(); i++) {
solutionsObserverList.add(i + 1 + ": " + solution.correctSolutionsArray.get(i) + "");
}
} else {
solutionsObserverList.add("No solutions were found");
}
solutionsListView.setItems(solutionsObserverList);
}
public void updateStructureLabels(Label wordLabel, Preperation problem, SmartSolve solution) {
String labelText = "";
for (int i = 0; i < problem.wordsArray.length; i++) {
//add the operator symbon before the last word
if (i == problem.wordsArray.length - 1) {
labelText = labelText + problem.operator;
}
labelText = labelText + problem.wordsArray[i] + "\n";
}
labelText += "----------" + "\n";
labelText += problem.summationWord;
wordLabel.setText(labelText);
}
public void updateAnswerLabels(Label summationLabel, Preperation problem, SmartSolve solution) {
String labelText = "";
for (int i = 0; i < problem.wordMap.size(); i++) {
if (i == problem.wordsArray.length - 1) {
labelText = labelText + problem.operator;
}
for (int j = 0; j < problem.wordMap.get("word" + i).length; j++) {
labelText = labelText + solution.correctSolutionsArray.get(0).get(problem.letterMap.get("W" + i + "L" + j));
}
labelText += "\n";
}
labelText += "----------" + "\n";
for (int i = 0; i < problem.summationWord.length(); i++) {
labelText += solution.correctSolutionsArray.get(0).get(problem.summationWord.substring(i, i + 1));
}
summationLabel.setText(labelText);
}
}