1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-23 16:00:09 -08:00

Implement the history data model.

This commit is contained in:
Danila Fedorin 2017-07-31 17:49:57 -07:00
parent d61cc7bb9c
commit 61ead67535
2 changed files with 48 additions and 1 deletions

View File

@ -1,5 +1,7 @@
package org.nwapw.abacus.fx;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
@ -20,11 +22,14 @@ public class AbacusController {
@FXML
private Button inputButton;
private ObservableList<HistoryModel> historyData;
private Abacus abacus;
@FXML
public void initialize(){
abacus = new Abacus();
historyData = FXCollections.observableArrayList();
}
@FXML
@ -37,7 +42,7 @@ public class AbacusController {
return;
}
NumberInterface evaluatedNumber = abacus.evaluateTree(constructedTree);
if(constructedTree == null){
if(evaluatedNumber == null){
outputText.setText(ERR_EVAL);
inputButton.setDisable(false);
return;

View File

@ -0,0 +1,42 @@
package org.nwapw.abacus.fx;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class HistoryModel {
private final StringProperty input;
private final StringProperty parsed;
private final StringProperty output;
public HistoryModel(String input, String parsed, String output){
this.input = new SimpleStringProperty();
this.parsed = new SimpleStringProperty();
this.output = new SimpleStringProperty();
this.input.setValue(input);
this.parsed.setValue(parsed);
this.output.setValue(output);
}
public StringProperty inputProperty() {
return input;
}
public String getInput() {
return input.get();
}
public StringProperty parsedProperty() {
return parsed;
}
public String getParsed() {
return parsed.get();
}
public StringProperty outputProperty() {
return output;
}
public String getOutput() {
return output.get();
}
}