FIX:: checkstyle
This commit is contained in:
@@ -12,26 +12,28 @@ public class Hints {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds all the Strings to the arraylist.
|
||||
* This method adds all the Strings to the array list.
|
||||
*/
|
||||
private void initHints() {
|
||||
this.hints.add("Buying local produce will not only decrease your carbon "
|
||||
+ "footprint, but also help your local economy: A win-win!");
|
||||
this.hints.add("Did you know that a gas oven only uses 6% of its energy "
|
||||
+ "to cook? And an electric oven is not much better at 12%.");
|
||||
this.hints.add("70% of the deforestation of the Amazon is to provide land for cattle ranches.");
|
||||
this.hints.add("70% of the deforestation of the Amazon is to provide land for "
|
||||
+ "cattle ranches.");
|
||||
this.hints.add("Research shows that reducing meat consumption can increase"
|
||||
+ " your life span by 3.6 years");
|
||||
this.hints.add("Vegetarians have a lower risk of getting heart disease, high blood pressure, "
|
||||
+ "diabetes and cancer than meat eaters.");
|
||||
this.hints.add("Vegetarians have a lower risk of getting heart disease, high blood "
|
||||
+ "pressure, diabetes and cancer than meat eaters.");
|
||||
this.hints.add("Did you know? The carbon footprint of a vegetarian diet is about half "
|
||||
+ "that of a meat-lover’s diet!");
|
||||
this.hints.add("Cycling is good for the environment AND for your body, "
|
||||
+ "so why not grab your bike instead of your car?");
|
||||
this.hints.add("If we could capture all of the sun’s energy shining on the Earth for just one "
|
||||
+ "hour, we could power the entire world for one year!");
|
||||
this.hints.add("If we could capture all of the sun’s energy shining on the Earth"
|
||||
+ " for just one hour, we could power the entire world for one year!");
|
||||
this.hints.add("27,000 trees are cut down each day so we can have toilet paper.");
|
||||
this.hints.add("A glass bottle made in our time will take more than 4,000 years to decompose.");
|
||||
this.hints.add("A glass bottle made in our time will take more than 4,000 years "
|
||||
+ "to decompose.");
|
||||
this.hints.add("Don't forget to turn off the lights and heating in rooms"
|
||||
+ " you're not using at the moment!");
|
||||
this.hints.add("Did you know that about 4.5% of the Dutch population does not eat meat?");
|
||||
@@ -63,7 +65,7 @@ public class Hints {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a random String.
|
||||
* This method gets a random String.
|
||||
* @return the random hint.
|
||||
*/
|
||||
public String randomHint() {
|
||||
|
||||
@@ -394,6 +394,128 @@ public class CalculatorController {
|
||||
userService.updateInput(userService.currentUser.getName(), "input_size",
|
||||
peopleInHouseHoldLabel.getText());
|
||||
}
|
||||
checkTransportLabels();
|
||||
checkHousingLabels();
|
||||
checkFoodLabels();
|
||||
if (!goodsLabel.getText().replace(" € / month", "").equals("1520")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_goods_total",
|
||||
goodsLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
if (!servicesLabel.getText().replace(" € / month", "").equals("3428")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_services_total",
|
||||
servicesLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
checkCheckBoxes();
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
Window owner = saveButton.getScene().getWindow();
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
controller.updateLeaderboard();
|
||||
CalculatorController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION,
|
||||
owner, "Footprint saved!", "Your footprint is saved!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the check boxes.
|
||||
*/
|
||||
public void checkCheckBoxes() {
|
||||
if (localProduceCheckbox.isSelected()) {
|
||||
localProduceCheckbox.setSelected(true);
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"local_produce", true);
|
||||
}
|
||||
if (bikeCheckbox.isSelected()) {
|
||||
bikeCheckbox.setSelected(true);
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"bike", true);
|
||||
}
|
||||
if (temperatureCheckbox.isSelected()) {
|
||||
temperatureCheckbox.setSelected(true);
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"temperature", true);
|
||||
}
|
||||
if (solarPanelsCheckbox.isSelected()) {
|
||||
solarPanelsCheckbox.setSelected(true);
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"solar_panels", true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the food labels.
|
||||
*/
|
||||
public void checkFoodLabels() {
|
||||
if (!meatFishEggsLabel.getText().replace(" daily servings per person", "").equals("2.6")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_meatfisheggs",
|
||||
meatFishEggsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!grainsBakedGoodsLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("4.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_cereals",
|
||||
grainsBakedGoodsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!dairyLabel.getText().replace(" daily servings per person", "").equals("2.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_dairy",
|
||||
dairyLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!fruitsVegetablesLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("3.9")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_fruitvegetables",
|
||||
fruitsVegetablesLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!snacksDrinksLabel.getText().replace(" daily servings per person", "").equals("3.7")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_otherfood",
|
||||
snacksDrinksLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the housing labels.
|
||||
*/
|
||||
public void checkHousingLabels() {
|
||||
if (!electricityField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_electricity_dollars",
|
||||
electricityField.getText());
|
||||
}
|
||||
if (!cleanEnergyPurchasedLabel.getText().replace(" %", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_gco2_per_kwh",
|
||||
cleanEnergyPurchasedLabel.getText().replace(" %", ""));
|
||||
}
|
||||
if (!naturalGasField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_naturalgas_dollars",
|
||||
naturalGasField.getText());
|
||||
}
|
||||
if (!heatingOilField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_heatingoil_dollars",
|
||||
heatingOilField.getText());
|
||||
}
|
||||
if (!livingSpaceField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_squarefeet",
|
||||
livingSpaceField.getText());
|
||||
}
|
||||
if (!waterUsageLabel.getText().replace("% of similar households", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_watersewage",
|
||||
waterUsageLabel.getText().replace("% of similar households", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the transport labels.
|
||||
*/
|
||||
public void checkTransportLabels() {
|
||||
if (!publicTransitField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_publictrans",
|
||||
@@ -434,99 +556,5 @@ public class CalculatorController {
|
||||
"input_footprint_transportation_mpg3",
|
||||
carTravelElectricLabel.getText().replace(" mpge", ""));
|
||||
}
|
||||
if (!electricityField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_electricity_dollars",
|
||||
electricityField.getText());
|
||||
}
|
||||
if (!cleanEnergyPurchasedLabel.getText().replace(" %", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_gco2_per_kwh",
|
||||
cleanEnergyPurchasedLabel.getText().replace(" %", ""));
|
||||
}
|
||||
if (!naturalGasField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_naturalgas_dollars",
|
||||
naturalGasField.getText());
|
||||
}
|
||||
if (!heatingOilField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_heatingoil_dollars",
|
||||
heatingOilField.getText());
|
||||
}
|
||||
if (!livingSpaceField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_squarefeet",
|
||||
livingSpaceField.getText());
|
||||
}
|
||||
if (!waterUsageLabel.getText().replace("% of similar households", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_watersewage",
|
||||
waterUsageLabel.getText().replace("% of similar households", ""));
|
||||
}
|
||||
if (!meatFishEggsLabel.getText().replace(" daily servings per person", "").equals("2.6")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_meatfisheggs",
|
||||
meatFishEggsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!grainsBakedGoodsLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("4.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_cereals",
|
||||
grainsBakedGoodsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!dairyLabel.getText().replace(" daily servings per person", "").equals("2.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_dairy",
|
||||
dairyLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!fruitsVegetablesLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("3.9")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_fruitvegetables",
|
||||
fruitsVegetablesLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!snacksDrinksLabel.getText().replace(" daily servings per person", "").equals("3.7")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_otherfood",
|
||||
snacksDrinksLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!goodsLabel.getText().replace(" € / month", "").equals("1520")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_goods_total",
|
||||
goodsLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
if (!servicesLabel.getText().replace(" € / month", "").equals("3428")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_services_total",
|
||||
servicesLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
if (localProduceCheckbox.isSelected()) {
|
||||
localProduceCheckbox.setSelected(true);
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"local_produce", true);
|
||||
}
|
||||
if (bikeCheckbox.isSelected()) {
|
||||
bikeCheckbox.setSelected(true);
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"bike", true);
|
||||
}
|
||||
if (temperatureCheckbox.isSelected()) {
|
||||
temperatureCheckbox.setSelected(true);
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"temperature", true);
|
||||
}
|
||||
if (solarPanelsCheckbox.isSelected()) {
|
||||
solarPanelsCheckbox.setSelected(true);
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"solar_panels", true);
|
||||
}
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
Window owner = saveButton.getScene().getWindow();
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
controller.updateLeaderboard();
|
||||
CalculatorController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION,
|
||||
owner, "Footprint saved!", "Your footprint is saved!");
|
||||
}
|
||||
}
|
||||
@@ -464,6 +464,9 @@ public class DashBoardController {
|
||||
calcStage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a random hint to the left.
|
||||
*/
|
||||
public void addRandomHints() {
|
||||
FadeTransition fadeOut = new FadeTransition(Duration.millis(400), hintText);
|
||||
fadeOut.setFromValue(1.0);
|
||||
|
||||
@@ -230,8 +230,7 @@ public class RegisterWindowController {
|
||||
//register the user with the provided username and password
|
||||
try {
|
||||
userService.registerUser(userNameText.getText(), passwordField.getText());
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
|
||||
"This username has already been taken!");
|
||||
return;
|
||||
@@ -456,6 +455,115 @@ public class RegisterWindowController {
|
||||
userService.updateInput(userService.currentUser.getName(), "input_size",
|
||||
peopleInHouseHoldLabel.getText());
|
||||
}
|
||||
checkTransportLabels();
|
||||
checkHousingLabels();
|
||||
checkFoodLabels();
|
||||
if (!goodsLabel.getText().replace(" € / month", "").equals("1520")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_goods_total",
|
||||
goodsLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
if (!servicesLabel.getText().replace(" € / month", "").equals("3428")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_services_total",
|
||||
servicesLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
if (localProduceCheckbox.isSelected()) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"local_produce", true);
|
||||
}
|
||||
if (bikeCheckbox.isSelected()) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"bike", true);
|
||||
}
|
||||
if (temperatureCheckbox.isSelected()) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"temperature", true);
|
||||
}
|
||||
if (solarPanelsCheckbox.isSelected()) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"solar_panels", true);
|
||||
}
|
||||
Float firstFootprint = userService.saveFirstFootprint(userService.currentUser.getName());
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
Window owner = saveButton.getScene().getWindow();
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the food labels.
|
||||
*/
|
||||
public void checkFoodLabels() {
|
||||
if (!meatFishEggsLabel.getText().replace(" daily servings per person", "").equals("2.6")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_meatfisheggs",
|
||||
meatFishEggsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!grainsBakedGoodsLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("4.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_cereals",
|
||||
grainsBakedGoodsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!dairyLabel.getText().replace(" daily servings per person", "").equals("2.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_dairy",
|
||||
dairyLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!fruitsVegetablesLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("3.9")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_fruitvegetables",
|
||||
fruitsVegetablesLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!snacksDrinksLabel.getText().replace(" daily servings per person", "").equals("3.7")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_otherfood",
|
||||
snacksDrinksLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the housing labels.
|
||||
*/
|
||||
public void checkHousingLabels() {
|
||||
if (!electricityField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_electricity_dollars",
|
||||
electricityField.getText());
|
||||
}
|
||||
if (!cleanEnergyPurchasedLabel.getText().replace(" %", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_gco2_per_kwh",
|
||||
cleanEnergyPurchasedLabel.getText().replace(" %", ""));
|
||||
}
|
||||
if (!naturalGasField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_naturalgas_dollars",
|
||||
naturalGasField.getText());
|
||||
}
|
||||
if (!heatingOilField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_heatingoil_dollars",
|
||||
heatingOilField.getText());
|
||||
}
|
||||
if (!livingSpaceField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_squarefeet",
|
||||
livingSpaceField.getText());
|
||||
}
|
||||
if (!waterUsageLabel.getText().replace("% of similar households", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_watersewage",
|
||||
waterUsageLabel.getText().replace("% of similar households", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the transport labels.
|
||||
*/
|
||||
public void checkTransportLabels() {
|
||||
if (!publicTransitField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_publictrans",
|
||||
@@ -496,93 +604,5 @@ public class RegisterWindowController {
|
||||
"input_footprint_transportation_mpg3",
|
||||
carTravelElectricLabel.getText().replace(" mpge", ""));
|
||||
}
|
||||
if (!electricityField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_electricity_dollars",
|
||||
electricityField.getText());
|
||||
}
|
||||
if (!cleanEnergyPurchasedLabel.getText().replace(" %", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_gco2_per_kwh",
|
||||
cleanEnergyPurchasedLabel.getText().replace(" %", ""));
|
||||
}
|
||||
if (!naturalGasField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_naturalgas_dollars",
|
||||
naturalGasField.getText());
|
||||
}
|
||||
if (!heatingOilField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_heatingoil_dollars",
|
||||
heatingOilField.getText());
|
||||
}
|
||||
if (!livingSpaceField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_squarefeet",
|
||||
livingSpaceField.getText());
|
||||
}
|
||||
if (!waterUsageLabel.getText().replace("% of similar households", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_watersewage",
|
||||
waterUsageLabel.getText().replace("% of similar households", ""));
|
||||
}
|
||||
if (!meatFishEggsLabel.getText().replace(" daily servings per person", "").equals("2.6")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_meatfisheggs",
|
||||
meatFishEggsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!grainsBakedGoodsLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("4.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_cereals",
|
||||
grainsBakedGoodsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!dairyLabel.getText().replace(" daily servings per person", "").equals("2.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_dairy",
|
||||
dairyLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!fruitsVegetablesLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("3.9")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_fruitvegetables",
|
||||
fruitsVegetablesLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!snacksDrinksLabel.getText().replace(" daily servings per person", "").equals("3.7")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_otherfood",
|
||||
snacksDrinksLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!goodsLabel.getText().replace(" € / month", "").equals("1520")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_goods_total",
|
||||
goodsLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
if (!servicesLabel.getText().replace(" € / month", "").equals("3428")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_services_total",
|
||||
servicesLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
if (localProduceCheckbox.isSelected()) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"local_produce", true);
|
||||
}
|
||||
if (bikeCheckbox.isSelected()) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"bike", true);
|
||||
}
|
||||
if (temperatureCheckbox.isSelected()) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"temperature", true);
|
||||
}
|
||||
if (solarPanelsCheckbox.isSelected()) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"solar_panels", true);
|
||||
}
|
||||
Float firstFootprint = userService.saveFirstFootprint(userService.currentUser.getName());
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
Window owner = saveButton.getScene().getWindow();
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,7 @@ public class UserController {
|
||||
//log the user in with the userService method
|
||||
try {
|
||||
userService.loginUser(usernameField.getText(), passwordField.getText());
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
|
||||
"Your username or password is incorrect!");
|
||||
return;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class AchievementService {
|
||||
* @param user user for whom achiev3 changes
|
||||
*/
|
||||
public void achieveGreenSaver(User user) {
|
||||
if (43-user.getFootPrint() > 38) {
|
||||
if (43 - user.getFootPrint() > 38) {
|
||||
userService.setAchievement(user.getName(), "Green saver", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import greenify.server.AllAchievements;
|
||||
import greenify.server.data.model.Achievement;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class AllAchievementsTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -3,11 +3,8 @@ package greenify.server.service;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
import greenify.server.data.model.User;
|
||||
import greenify.server.data.repository.UserRepository;
|
||||
import greenify.server.InputValidator;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
Reference in New Issue
Block a user