/**
* Currently stored amount of fuel in L
*/
- private float stored_amount;
+ private double stored_amount;
/**
* Maximum fuel storage capacity in L
*
* @author Robin Cheney
*/
- public float getStored_amount() {
+ public double getStored_amount() {
return stored_amount;
}
*
* @author Robin Cheney
*/
- public void setStored_amount(float stored_amount) {
+ public void setStored_amount(double stored_amount) {
this.stored_amount = stored_amount;
}
*
* @author Nils Göbbert
*/
- public void set_stored_amount(float new_amount, FuelType type) throws NoSuchFuelTypeError {
+ public void set_stored_amount(double new_amount, FuelType type) throws NoSuchFuelTypeError {
for (Fuel i : fuels) {
if (i.FUEL_TYPE == type) {
i.setStored_amount(new_amount);
*
* @author Nils Göbbert
*/
- public void add_stored_amount(float new_amount, FuelType type) throws NoSuchFuelTypeError, ArithmeticException {
+ public void add_stored_amount(double new_amount, FuelType type) throws NoSuchFuelTypeError, ArithmeticException {
for (Fuel i : fuels) {
if (i.FUEL_TYPE == type) {
if (new_amount + i.getStored_amount() < 0) {
}
}
- result.addAll(large);
- result.addAll(medium);
result.addAll(small);
+ result.addAll(medium);
+ result.addAll(large);
return result.toArray(new FuelStation[0]);
}
}
}
- result.addAll(large);
- result.addAll(medium);
result.addAll(small);
+ result.addAll(medium);
+ result.addAll(large);
+ // System.out.print(result);
return result.toArray(new FuelStation[0]);
}
*
* @author Nils Göbbert
*/
- public float getStored_amount(FuelType fuel_type) throws NoSuchFuelTypeError {
+ public double getStored_amount(FuelType fuel_type) throws NoSuchFuelTypeError {
for (Fuel i : fuels) {
if (i.FUEL_TYPE == fuel_type) {
return i.getStored_amount();
*/
public static FuelStation getHighestStoredAmount(FuelType fuelType) throws NoSuchFuelTypeError {
FuelStation highestStation = null;
- float highestAmount = Float.NEGATIVE_INFINITY;
+ double highestAmount = Double.NEGATIVE_INFINITY;
for (FuelStation fuelStation : fuelStations) {
try {
- float amount = fuelStation.getStored_amount(fuelType);
+ double amount = fuelStation.getStored_amount(fuelType);
if (amount > highestAmount) {
highestAmount = amount;
highestStation = fuelStation;
*/
public static FuelStation getLowestStoredAmount(FuelType fuelType) throws NoSuchFuelTypeError {
FuelStation lowestStation = null;
- float lowestAmount = Float.POSITIVE_INFINITY;
+ double lowestAmount = Double.POSITIVE_INFINITY;
for (FuelStation fuelStation : fuelStations) {
try {
- float amount = fuelStation.getStored_amount(fuelType);
+ double amount = fuelStation.getStored_amount(fuelType);
if (amount < lowestAmount) {
lowestAmount = amount;
lowestStation = fuelStation;
private VBox newStationTabContainer;
@FXML
private BorderPane overviewTabContainer;
+ @FXML
+ private VBox understaffedTabContainer;
// Controllers of included tabs
private ResultTabController resultTabController;
private SearchTabController searchTabController;
private NewStationTabController newStationTabController;
private OverviewTabController overviewTabController;
+ private UnderstaffedTabController understaffedTabController;
/**
* Automatically called initialize() function.
overviewTabController.setParentController(this);
// overviewTabController.refresh();
});
+ loadTab("/ui/UnderstaffedTab.fxml", understaffedTabContainer,
+ (UnderstaffedTabController c) -> {
+ understaffedTabController = c;
+ understaffedTabController.setParentController(this);
+ });
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
+import javafx.beans.property.SimpleDoubleProperty;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.Parent;
@FXML
private TableColumn<FuelRow, String> colFuel;
@FXML
- private TableColumn<FuelRow, Float> colAmount;
+ private TableColumn<FuelRow, Double> colAmount;
@FXML
private TableColumn<FuelRow, Integer> colCapacity;
@FXML
colStation.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getStation()));
colType.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getType()));
colFuel.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getFuel()));
- colAmount.setCellValueFactory(data -> new SimpleFloatProperty(data.getValue().getAmount()).asObject());
+ colAmount.setCellValueFactory(data -> new SimpleDoubleProperty(data.getValue().getAmount()).asObject());
colCapacity.setCellValueFactory(data -> new SimpleIntegerProperty(data.getValue().getCapacity()).asObject());
colPrice.setCellValueFactory(data -> new SimpleFloatProperty(data.getValue().getPrice()).asObject());
}
String station;
String type;
String fuel;
- float amount;
+ double amount;
int capacity;
float price;
this.fuel = fuel;
}
- public float getAmount() {
+ public double getAmount() {
return amount;
}
- public void setAmount(float amount) {
+ public void setAmount(double amount) {
this.amount = amount;
}
this.price = price;
}
- public FuelRow(String station, String type, String fuel, float amount, int capacity, float price) {
+ public FuelRow(String station, String type, String fuel, double amount, int capacity, float price) {
this.station = station;
this.type = type;
this.fuel = fuel;
}
try {
- float value = Float.parseFloat(txtAmount.getText().replace(",", "."));
+ double value = Double.parseDouble(txtAmount.getText().replace(",", "."));
int capacity = getCapacity(station, type);
- float current = station.getStored_amount(type);
+ double current = station.getStored_amount(type);
if (rbAbsolute.isSelected()) {
if (value < 0 || value > capacity) {
parentController.appendOutput("Stock of %s at %s set to %.2f L"
.formatted(type, parentController.getDisplayName(station), value));
} else {
- float updated = current + value;
+ double updated = current + value;
if (updated < 0 || updated > capacity) {
parentController.showError("Out of capacity bounds.");
return;
--- /dev/null
+package de.diejungsvondertanke.tankstelle.controllers;
+
+import java.io.IOException;
+
+import de.diejungsvondertanke.tankstelle.FuelStation;
+import de.diejungsvondertanke.tankstelle.Main;
+import javafx.fxml.FXML;
+import javafx.scene.control.TextField;
+
+public class UnderstaffedTabController {
+
+ @FXML
+ private TextField pin, staffCount;
+
+ private FuelStationUIController parentController;
+
+ // Called by parent after full initialization
+ public void setParentController(FuelStationUIController parent) {
+ this.parentController = parent;
+ }
+
+ @FXML
+ private void show() {
+ try {
+
+ if (Main.isPINCorrect(pin.getText())) {
+ try {
+ if (Integer.parseInt(staffCount.getText()) <= Main.getTotalNumberOfEmployees()) {
+ String out = "";
+ for (FuelStation station : Main
+ .getFuelStationListWhenUnderstaffed(Short.parseShort(staffCount.getText()))) {
+ out += "\n - %s".formatted(parentController.getDisplayName(station));
+ }
+ parentController.appendOutput("Fuel stations that can be operated:" + out);
+ } else {
+ parentController.appendOutput("You don't have that many employees!");
+ }
+ } catch (Exception e) {
+ }
+ } else {
+ parentController.appendOutput("invalid PIN");
+ }
+ } catch (IOException e) {
+ }
+ }
+
+}
<Tab text="Overview" closable="false">
<BorderPane fx:id="overviewTabContainer" />
</Tab>
+ <Tab text="Understaffed" closable="false">
+ <VBox fx:id="understaffedTabContainer" />
+ </Tab>
</tabs>
</TabPane>
</center>
<?import javafx.scene.layout.*?>
<VBox xmlns:fx="http://javafx.com/fxml"
- fx:controller="de.diejungsvondertanke.tankstelle.controllers.StockTabController" spacing="10">
+ fx:controller="de.diejungsvondertanke.tankstelle.controllers.StockTabController" spacing="10">
<padding>
<Insets top="15" right="15" bottom="15" left="15" />
</padding>
<TextField fx:id="txtAmount" />
</HBox>
- <RadioButton fx:id="rbAbsolute" text="Set absolute" selected="true" />
- <RadioButton fx:id="rbDelta" text="Change (+/-)" />
+ <fx:define>
+ <ToggleGroup fx:id="group" />
+ </fx:define>
+ <RadioButton fx:id="rbAbsolute" toggleGroup="$group" text="Set absolute" selected="true" />
+ <RadioButton fx:id="rbDelta" toggleGroup="$group" text="Change (+/-)" />
<Button text="Change stock" onAction="#save" />
</VBox>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<?import javafx.geometry.Insets?>
+<?import javafx.scene.control.*?>
+<?import javafx.scene.layout.*?>
+
+<VBox xmlns:fx="http://javafx.com/fxml"
+ fx:controller="de.diejungsvondertanke.tankstelle.controllers.UnderstaffedTabController"
+ spacing="10">
+
+ <padding>
+ <Insets top="15" right="15" bottom="15" left="15" />
+ </padding>
+
+ <Label
+ text="Show a list of fuel stations in the output window, which can be opened with the reduced staff count available" />
+
+ <Label text="PIN: " />
+ <HBox>
+ <TextField fx:id="pin" />
+ </HBox>
+
+ <Label text="no. of staff members available: " />
+ <HBox>
+ <TextField fx:id="staffCount" />
+ </HBox>
+
+ <Button text="Show stations" onAction="#show" />
+</VBox>
\ No newline at end of file