diff --git a/README.md b/README.md
index 87cc6a7..8960e00 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,47 @@
-## Getting your weekly reports
+# Greenify
+The easiest way to save CO2 and help the environment! Enter your activities and find out your carbon footprint.
-**Jacoco**:
-Run `maven install` ([Intellij](https://www.jetbrains.com/help/idea/2016.3/getting-started-with-maven.html#execute_maven_goal)/[Eclipse](http://imgur.com/a/6q7pV))
+## Getting started
+You can install greenify with gradle, if you already have gradle on your machine, run:
-**Checkstyle**:
-Run `maven site`
+```
+gradle install something tralala
+```
-# Merel Steenbergen (masteenbergen)
-
+Do you not have gradle on your machine, run:
-## Personal Development Plan
+```
+./gradlew install something tralala
+```
+
+With the following you can start the application
+
+```
+gradle greenify bootrun
+```
+
+or without gradle on your device:
+
+```
+./gradlew greenify bootrun
+```
+
+## Running the tests
+The tests cover all non-GUI code:
+
+```
+gradle check
+```
+
+## Licence
+GNU General Public License v3.0
+
+## Contributors
+
+### Merel Steenbergen (masteenbergen)
+
+
+#### Personal Development Plan
My strong points:
1. I’m a natural leader. I like to know how everyone is doing, if
@@ -19,37 +51,37 @@ everyone is keeping on track and if not, why is someone slacking?
What are two of your weaker points?
1. I’m a bit of a control freak. Sometimes I find it hard to let other people do things and to mind my own business.
2. I’m competitive. This can be a good thing, because I’m very passionate and really give it 100% if I like something, but it can also lead to hurt feelings when I’m not paying attention.
-
-
-### G - Goal
+
+
+##### G - Goal
I want to improve on letting other people handle things that I actually want to do myself. I also want to improve my programming and am aiming to not make it a competition, but to really make it a group project. This is important, because you almost never work alone in software developing, which is what I want to do after the studies.
-### R - Reality (Your current situation)
+##### R - Reality (Your current situation)
I’ve already been working on my teamwork skills since high school. I had a subject that had only projects. I’ve also worked with Scrum before, which really helps you focus on your development without letting your project out of sight. I’m better at working together and listening to tips than I was before.
-### O - Options (Look at possible options)
+##### O - Options (Look at possible options)
Actively watching myself and letting my teammates know that they need to be clear with me if they don’t like something I say or do are the best ways for me to improve. I would rather improve by myself, but for my goals it is better to let my team guide me. It’s about teamwork after all.
-### W - Will (Motivation, plan of action)
+##### W - Will (Motivation, plan of action)
I’m just going to keep working on myself and hope my teammates will work with me. It also helps to work in different teams to get a much more diverse experience. Every team is different, so I’m just going to wait what this team will bring me and how I will have to adjust myself to make the team efficient.
-# Sem van der Hoeven (4896726, semvanderhoeve)
-
+### Sem van der Hoeven (4896726, semvanderhoeve)
+
-## Personal development plan
-
+#### Personal development plan
+
-### G - Goal
+##### G - Goal
My goal with this project is most of all to be able to efficiently work with a group of people. This is important to me because I have not worked on a (development) project with a (big) group of people before. I believe I have succeeded in this goal when our project is finished and we have got a passing grade.
-### R - Reality
+##### R - Reality
With this project I am already setting the first step towards reaching my goal, as we have already started working as a group.
-### O - Options
+##### O - Options
The options I have to reach my goal are basically this project, as this is the only big project we will be doing as a team in this year. I want to obviously try to learn as much as I can during this project, especially abour working in a group. The only thing I think would be stopping this is if members of the group had different opinions on how things should be done. but so far everyone is on the same track :D.
-### W - Will
+##### W - Will
I am going to try my hardest to follow the rules we have set up, and to deliver everything I am supposed to. I will try to do this everytime I get the chance to do so. Right now the first step I can take is to work on this personal development plan, so that I already have my part of what we needed to do finished. My teammates can help me achieve this goal by helping if I have questions or don't understand something/am getting stuck with something.
action plan:
⋅⋅* finish my part of the readme that we have to finish
@@ -57,13 +89,11 @@ action plan:
⋅⋅* don't be hesitant on asking people for help
⋅⋅* deliver things I need to do on time
-# Ceren Ugurlu (4851609, cugurlu)
+### Ceren Ugurlu (4851609, cugurlu)
+
-
-
-## Personal Development Plan:
-
-- This is my core quadrant: 
+#### Personal Development Plan:
+
My strong points:
- I am an ambitious person in order to achieve my goal I can study a lot
@@ -73,7 +103,7 @@ My strong points:
My weaker points:
- Sometimes I can be a stressed and anxious person. If we have a difficulty about time management etc. I can get stressed. But if we work efficiently as a team, I do not think this is going to be a problem
-### G – Goal
+##### G – Goal
My goals in this project:
- Developing my Java skills
- Learning how to work effectively as a team
@@ -81,13 +111,13 @@ My goals in this project:
I am aiming to successfully finish the parts that belong to me in our project. To achieve this, I should develop my Java skills. I want to contribute to my group and to learn new things from my teammates. When we finish our project, I will be achieved my goal.
-### R – Reality
+##### R – Reality
This is my first team project. I have never experienced this before. I have done some similar programs in different languages but this is the first one in Java. This is both exciting and hard. There are many things I need to do but I like to study and develop myself.
-### O – Options
+##### O – Options
There are two options to achieve and not to achieve but I do not want to count the second one as an option because we are a team. And teamwork means that many different perspectives and a lot of human power. Therefore, I can say that there is not any reason for an unsuccessful result. If it happens, it is also not a problem. It shows that I need to develop myself. I would try to learn new things from my mistakes.
-### W – Will
+##### W – Will
I will try to do my best to be successful in our project and I am going to start right now for this. The first step I can take is creating a plan with my group mates and to start our project according to this plan.
Action Plan:
@@ -97,11 +127,11 @@ Action Plan:
- Starting to code (informing each other about the steps we have took)
- While everyone is working on their part, to inform each other about the progress is very important because some parts can be connected. When two people's parts are connected they should act according to that otherwise it can lead problems or a non-compiling code)
-# Mika Wauben (4834739, mlwauben)
-
+### Mika Wauben (4834739, mlwauben)
+
-## Personal Development Plan
-
+#### Personal Development Plan
+
My strong points:
1. I am observing and think before I speak.
@@ -111,14 +141,14 @@ Action Plan:
1. I like to do things alone. I rather figure something out myself instead of asking for help, even if this takes way too long.
2. I tend to stay quiet if I'm not absolutely sure my contribution is right or useful.
-### G - Goal
+##### G - Goal
My goal during this course is getting more experienced in working with things like github, libraries, scrumboard, etc. and asking for help if I need it, since being stuck on something isn’t going to help my groupmates.
-### R - Reality
+##### R - Reality
Every minute that we’re working on the project, I’m also actively working on my goal.
-### O - Options
+##### O - Options
By working on the project with the chosen programs, I’ll get more experienced in using them. Using those programs for other projects as well will only improve my knowledge. By being active in the groupchat and during the meetings, asking stuff will be easier.
-### W - Will
+##### W - Will
I will reach my goal by working actively together with my teammates using lots of the useful programs given.
diff --git a/doc/meetings/week8/20190401_agenda.md b/doc/meetings/week8/20190401_agenda.md
new file mode 100644
index 0000000..13c8bd9
--- /dev/null
+++ b/doc/meetings/week8/20190401_agenda.md
@@ -0,0 +1,47 @@
+# Meeting 7
+
+## Opening
+> Check if everyone is present:
+- ~~Nivard Jansen~~
+- ~~Kristin Peneva~~
+- ~~Daan Sneep~~
+- [x] Merel SteenBergen
+- [x] Ceren Ugurlu
+- [x] Mika Wauben
+- [x] Sem van der Hoeven
+
+- Chair: Mika Wauben
+- Secretary: Ceren Ugurlu
+
+## Points of action
+
+ - First of all, discuss problems we have faced and if somebody is halted because of a problem
+ - if so, try to work out the problem
+
+### pre/during meeting
+ - Discuss what we did last week (see scrumboard)
+ - Does anyone have blocking issues?
+ - Gitlab
+ - CI
+ - Coverage reports
+ - Checkstyle reports
+ - Show demo 3 to the TA
+ - Discuss about the presentation
+ - Discuss about final things that need to be done
+
+### post meeting
+ - Focus on the presentation
+ - Focus on the final report
+ - Focus on things we get points for according to the rubric
+
+## Any other business
+> If anybody has something that should be discussed but came up with that after the agenda was finalized, he/she should bring that up now so that it can be discussed after all.
+
+## Question round
+- Questions for the TA
+ - questions that were already present
+ - Ask about custom CI (do we have it already?)
+ - questions that rose during the meeting
+
+## Closing
+> We're almost finished!
diff --git a/doc/meetings/week8/20190401_notes.pdf b/doc/meetings/week8/20190401_notes.pdf
new file mode 100644
index 0000000..9fd2068
Binary files /dev/null and b/doc/meetings/week8/20190401_notes.pdf differ
diff --git a/doc/reports/checkstyle/20190401_checkstyle.png b/doc/reports/checkstyle/20190401_checkstyle.png
new file mode 100644
index 0000000..27818b2
Binary files /dev/null and b/doc/reports/checkstyle/20190401_checkstyle.png differ
diff --git a/doc/reports/coverage/20190401_coverage.png b/doc/reports/coverage/20190401_coverage.png
new file mode 100644
index 0000000..faa2912
Binary files /dev/null and b/doc/reports/coverage/20190401_coverage.png differ
diff --git a/doc/reports/final-report/20190401_draft_final_report.pdf b/doc/reports/final-report/20190401_draft_final_report.pdf
new file mode 100644
index 0000000..0faf037
Binary files /dev/null and b/doc/reports/final-report/20190401_draft_final_report.pdf differ
diff --git a/doc/reports/sprint-reviews/20190401_sprint_review.md b/doc/reports/sprint-reviews/20190401_sprint_review.md
new file mode 100644
index 0000000..44f2e1a
--- /dev/null
+++ b/doc/reports/sprint-reviews/20190401_sprint_review.md
@@ -0,0 +1,14 @@
+
+# Sprint Review
+
+## Main problems Encountered
+
+### Problem 1: We had some bugs
+because of some bugs in the server, things did not work as intended. Ceren fixed it.
+
+## Adjustments from previous sprints
+Write all we still need to do down, even if the things are not necessarily assigned to a specific person yet.
+
+## Adjustments for next sprint
+ - Write down all other necessary tasks.
+
diff --git a/doc/sprints/sprint5/20190401_scrumboard.png b/doc/sprints/sprint5/20190401_scrumboard.png
new file mode 100644
index 0000000..d9fcb16
Binary files /dev/null and b/doc/sprints/sprint5/20190401_scrumboard.png differ
diff --git a/doc/sprints/sprint5/retrospective_sprint5.pdf b/doc/sprints/sprint5/retrospective_sprint5.pdf
new file mode 100644
index 0000000..1edab6f
Binary files /dev/null and b/doc/sprints/sprint5/retrospective_sprint5.pdf differ
diff --git a/doc/sprints/sprint6/.gitkeep b/doc/sprints/sprint6/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/doc/sprints/sprint6/backlog_sprint6.pdf b/doc/sprints/sprint6/backlog_sprint6.pdf
new file mode 100644
index 0000000..f5fd2ea
Binary files /dev/null and b/doc/sprints/sprint6/backlog_sprint6.pdf differ
diff --git a/quality/checkstyle/suppression.xml b/quality/checkstyle/suppression.xml
deleted file mode 100644
index 32fd9c0..0000000
--- a/quality/checkstyle/suppression.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/src/Client/src/main/java/greenify/client/Hints.java b/src/Client/src/main/java/greenify/client/Hints.java
index 5130954..34aa3fb 100644
--- a/src/Client/src/main/java/greenify/client/Hints.java
+++ b/src/Client/src/main/java/greenify/client/Hints.java
@@ -52,11 +52,11 @@ public class Hints {
+ "utensils and napkins, it saves plastic and paper.");
hints.add("It takes about 66 days to form a new habit, keep going!");
hints.add("Get yourself a nice reusable water bottle! It's cheaper and better for "
- + "the environment to refill than to buy a new one every time it's empty.");
+ + "the environment to refill than to buy a new one every time it's empty.");
}
/**
- * This method gets a random hint from the list of hints.
+ * This method returns a random hint from the list of hints.
* @return the random hint.
*/
public String randomHint() {
diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java
index 06f2a2e..d2ab3d3 100644
--- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java
+++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java
@@ -1,33 +1,42 @@
package greenify.client.controller;
+import greenify.client.Application;
import greenify.client.rest.UserService;
+import javafx.animation.Interpolator;
+import javafx.animation.KeyFrame;
+import javafx.animation.KeyValue;
+import javafx.animation.Timeline;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
+import javafx.scene.Node;
import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
+import javafx.scene.control.ScrollPane;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
+import javafx.scene.text.Text;
+import javafx.stage.Stage;
+import javafx.stage.Window;
+import javafx.util.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
+import java.io.IOException;
+import java.text.DecimalFormat;
+
@Controller
public class CalculatorController {
@Autowired
UserService userService;
- @FXML
- private Button calculatorGetStartedButton;
- @FXML
- private Button calculatorTravelButton;
- @FXML
- private Button calculatorHomeButton;
- @FXML
- private Button calculatorFoodButton;
- @FXML
- private Button calculatorShoppingButton;
+ @Autowired
+ DashBoardController controller;
+
+ //navigation panes
@FXML
private AnchorPane getStartedPane;
@FXML
@@ -35,9 +44,11 @@ public class CalculatorController {
@FXML
private AnchorPane homePane;
@FXML
- private AnchorPane foodPane;
+ private ScrollPane foodPane;
@FXML
private AnchorPane shoppingPane;
+
+ //'get started' pane
@FXML
private Slider peopleInHouseholdSlider;
@FXML
@@ -48,19 +59,106 @@ public class CalculatorController {
private Label annualIncomeLabel;
@FXML
private Button saveButton;
+
+ //travel pane
@FXML
private TextField publicTransitField;
@FXML
private TextField airplaneTravelField;
+ @FXML
+ private TextField carTravelGasolineField;
+ @FXML
+ private Slider carTravelGasolineSlider;
+ @FXML
+ private Label carTravelGasolineLabel;
+ @FXML
+ private TextField carTravelDieselField;
+ @FXML
+ private Slider carTravelDieselSlider;
+ @FXML
+ private Label carTravelDieselLabel;
+ @FXML
+ private TextField carTravelElectricField;
+ @FXML
+ private Slider carTravelElectricSlider;
+ @FXML
+ private Label carTravelElectricLabel;
+
+ //home pane
+ @FXML
+ private TextField electricityField;
+ @FXML
+ private Slider cleanEnergyPurchasedSlider;
+ @FXML
+ private Label cleanEnergyPurchasedLabel;
+ @FXML
+ private TextField naturalGasField;
+ @FXML
+ private TextField heatingOilField;
+ @FXML
+ private TextField livingSpaceField;
+ @FXML
+ private Slider waterUsageSlider;
+ @FXML
+ private Label waterUsageLabel;
+
+ //food pane
+ @FXML
+ private Slider meatFishEggsSlider;
+ @FXML
+ private Label meatFishEggsLabel;
+ @FXML
+ private Slider grainsBakedGoodsSlider;
+ @FXML
+ private Label grainsBakedGoodsLabel;
+ @FXML
+ private Slider dairySlider;
+ @FXML
+ private Label dairyLabel;
+ @FXML
+ private Slider fruitsVegetablesSlider;
+ @FXML
+ private Label fruitsVegetablesLabel;
+ @FXML
+ private Slider snacksDrinksSlider;
+ @FXML
+ private Label snacksDrinksLabel;
+
+ //shopping pane
+ @FXML
+ private Text goodsField;
+ @FXML
+ private Text servicesField;
+ @FXML
+ private Slider goodsSlider;
+ @FXML
+ private Label goodsLabel;
+ @FXML
+ private Slider servicesSlider;
+ @FXML
+ private Label servicesLabel;
+
+ //extra pane
+ @FXML
+ private AnchorPane extraPane;
+ @FXML
+ private CheckBox localProduceCheckbox;
+ @FXML
+ private CheckBox bikeCheckbox;
+ @FXML
+ private CheckBox temperatureCheckbox;
+ @FXML
+ private CheckBox solarPanelsCheckbox;
+
/**
* initializes the window, performs some actions before loading all other things.
- * it sets the sliders to snap to the ticks
- * it adds listeners to all the sliders for updating the label next to them
+ * it sets the sliders to snap to the ticks.
+ * it adds listeners to all the sliders for updating the label they are associated with.
*/
+ @SuppressWarnings("Duplicates")
public void initialize() {
peopleInHouseholdSlider.setSnapToTicks(true);
- annualIncomeSlider.setSnapToTicks(true);
//add listener to slider for amount of people in household
peopleInHouseholdSlider.valueProperty().addListener(new ChangeListener() {
@@ -78,6 +176,80 @@ public class CalculatorController {
annualIncomeLabel.setText("" + (newValue.intValue() * 1000));
}
});
+
+ addSliderListenerCarUsage(carTravelGasolineSlider, carTravelGasolineLabel, " km/L");
+ addSliderListenerCarUsage(carTravelDieselSlider, carTravelDieselLabel, " km/L");
+ addSliderListenerCarUsage(carTravelElectricSlider, carTravelElectricLabel, " km/Le");
+
+ cleanEnergyPurchasedSlider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ cleanEnergyPurchasedLabel.setText(newValue.intValue() + " %");
+ }
+ });
+
+ waterUsageSlider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ waterUsageLabel.setText(newValue.intValue() + "% of similar households");
+ }
+ });
+
+ addSliderListenerDailyServing(meatFishEggsSlider, meatFishEggsLabel);
+ addSliderListenerDailyServing(grainsBakedGoodsSlider, grainsBakedGoodsLabel);
+ addSliderListenerDailyServing(dairySlider, dairyLabel);
+ addSliderListenerDailyServing(fruitsVegetablesSlider, fruitsVegetablesLabel);
+ addSliderListenerDailyServing(snacksDrinksSlider, snacksDrinksLabel);
+
+ addSliderListenerGoodsServices(goodsSlider, goodsLabel);
+ addSliderListenerGoodsServices(servicesSlider, servicesLabel);
+ }
+
+ /**
+ * adds the listener to the given slider and displays it's output on a given label.
+ * @param slider the slider to attach the listener to.
+ * @param label the label to display the slider output on.
+ */
+ private void addSliderListenerCarUsage(Slider slider, Label label, String unit) {
+ slider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ label.setText(newValue.intValue() + unit);
+ }
+ });
+ }
+
+ @SuppressWarnings("Duplicates")
+ private void addSliderListenerDailyServing(Slider slider, Label label) {
+ DecimalFormat df = new DecimalFormat("0.0");
+ slider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ label.setText(df.format(newValue.doubleValue()) + " daily servings per person");
+ }
+ });
+ }
+
+ private void addSliderListenerGoodsServices(Slider slider, Label label) {
+ slider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ label.setText(newValue.intValue() + "€ / month");
+ }
+ });
+ }
+
+ private void addSlideInAnimation(Node node) {
+ Timeline timeline = new Timeline();
+ KeyValue keyValue = new KeyValue(node.translateXProperty(), 0, Interpolator.EASE_OUT);
+ KeyFrame keyFrame = new KeyFrame(Duration.millis(600), keyValue);
+ timeline.getKeyFrames().add(keyFrame);
+ timeline.play();
}
/**
@@ -85,12 +257,15 @@ public class CalculatorController {
* Activated when the designated button (navigation button) is clicked
* @param event the click of the button
*/
+ @SuppressWarnings("Duplicates")
public void displayGetStarted(ActionEvent event) {
+
getStartedPane.setVisible(true);
travelPane.setVisible(false);
homePane.setVisible(false);
foodPane.setVisible(false);
shoppingPane.setVisible(false);
+ extraPane.setVisible(false);
}
@@ -99,12 +274,16 @@ public class CalculatorController {
* Activated when the designated button (navigation button) is clicked
* @param event the click of the button
*/
+ @SuppressWarnings("Duplicates")
public void displayTravel(ActionEvent event) {
+
getStartedPane.setVisible(false);
travelPane.setVisible(true);
homePane.setVisible(false);
foodPane.setVisible(false);
shoppingPane.setVisible(false);
+ extraPane.setVisible(false);
+
}
/**
@@ -112,12 +291,15 @@ public class CalculatorController {
* Activated when the designated button (navigation button) is clicked
* @param event the click of the button
*/
+ @SuppressWarnings("Duplicates")
public void displayHome(ActionEvent event) {
+
getStartedPane.setVisible(false);
travelPane.setVisible(false);
homePane.setVisible(true);
foodPane.setVisible(false);
shoppingPane.setVisible(false);
+ extraPane.setVisible(false);
}
/**
@@ -125,12 +307,15 @@ public class CalculatorController {
* Activated when the designated button (navigation button) is clicked
* @param event the click of the button
*/
+ @SuppressWarnings("Duplicates")
public void displayFood(ActionEvent event) {
+
getStartedPane.setVisible(false);
travelPane.setVisible(false);
homePane.setVisible(false);
foodPane.setVisible(true);
shoppingPane.setVisible(false);
+ extraPane.setVisible(false);
}
/**
@@ -138,36 +323,186 @@ public class CalculatorController {
* Activated when the designated button (navigation button) is clicked
* @param event the click of the button
*/
+ @SuppressWarnings("Duplicates")
public void displayShopping(ActionEvent event) {
+
getStartedPane.setVisible(false);
travelPane.setVisible(false);
homePane.setVisible(false);
foodPane.setVisible(false);
shoppingPane.setVisible(true);
+ extraPane.setVisible(false);
+ }
+
+ /**
+ * displays the 'Extra' section of the calculator.
+ * Activated when the designated button (navigation button) is clicked
+ * @param event the click of the designated button
+ */
+ @SuppressWarnings("Duplicates")
+ public void displayExtra(ActionEvent event) throws IOException {
+
+ extraPane.getChildren().setAll((Node) Application.load(this.getClass()
+ .getClassLoader().getResource("fxml/extraActivities.fxml")));
+ getStartedPane.setVisible(false);
+ travelPane.setVisible(false);
+ homePane.setVisible(false);
+ foodPane.setVisible(false);
+ shoppingPane.setVisible(false);
+ extraPane.setVisible(true);
+
}
/**
* The method saves the calculation.
* @param event user clicks to button
*/
- public void saveCalculation(ActionEvent event) {
+ @SuppressWarnings("Duplicates")
+ public void saveCalc(ActionEvent event) throws InterruptedException {
getStartedPane.setVisible(false);
travelPane.setVisible(false);
homePane.setVisible(false);
foodPane.setVisible(false);
shoppingPane.setVisible(false);
- if (!annualIncomeLabel.getText().equals(null)) {
+ if (!annualIncomeLabel.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(), "input_income",
annualIncomeLabel.getText());
}
- if (!peopleInHouseHoldLabel.getText().equals(null)) {
- userService.updateInput(userService.currentUser.getName(), "input_population",
+ if (!peopleInHouseHoldLabel.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(), "input_size",
peopleInHouseHoldLabel.getText());
}
- userService.updateInput(userService.currentUser.getName(),
- "input_footprint_housing_naturalgas_cuft", "0");
- userService.updateInput(userService.currentUser.getName(),
- "input_footprint_transportation_miles1", "0");
+ if (!publicTransitField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_publictrans",
+ publicTransitField.getText());
+ }
+ if (!airplaneTravelField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_airtotal",
+ airplaneTravelField.getText());
+ }
+ if (!carTravelGasolineField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_miles1",
+ carTravelGasolineField.getText());
+ }
+ if (!carTravelGasolineLabel.getText().replace(" mpg", "").equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_mpg1",
+ carTravelGasolineLabel.getText().replace(" mpg", ""));
+ }
+ if (!carTravelDieselField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_miles2",
+ carTravelDieselField.getText());
+ }
+ if (!carTravelDieselLabel.getText().replace(" mpg", "").equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_mpg2",
+ carTravelDieselLabel.getText().replace(" mpg", ""));
+ }
+ if (!carTravelElectricField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_miles3",
+ carTravelElectricField.getText());
+ }
+ if (!carTravelElectricLabel.getText().replace(" mpge", "").equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "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();
}
-}
-
+}
\ No newline at end of file
diff --git a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java
index 471e8d4..daeb661 100644
--- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java
+++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java
@@ -418,10 +418,11 @@ public class DashBoardController {
extraStage.setScene(scene);
extraStage.setTitle("Add extra activity - " + userService.currentUser.getName());
extraStage.show();
+
}
/**
- * method opens addFriend scene.
+ * method opend addFriend scene.
* @throws IOException when file is not found
*/
public void openAddFriend() throws IOException {
@@ -526,4 +527,5 @@ public class DashBoardController {
button.setOnMouseExited(e -> scaleDown.playFromStart());
}
}
+
}
diff --git a/src/Client/src/main/java/greenify/client/controller/ExtraActivityController.java b/src/Client/src/main/java/greenify/client/controller/ExtraActivityController.java
new file mode 100644
index 0000000..ecb9ba3
--- /dev/null
+++ b/src/Client/src/main/java/greenify/client/controller/ExtraActivityController.java
@@ -0,0 +1,138 @@
+package greenify.client.controller;
+
+import greenify.client.rest.UserService;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.Slider;
+import javafx.scene.layout.AnchorPane;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class ExtraActivityController {
+
+ @Autowired
+ UserService userService;
+
+ @FXML
+ private AnchorPane veganMealPane;
+ @FXML
+ private AnchorPane bikePane;
+ @FXML
+ private AnchorPane temperaturePane;
+ @FXML
+ private AnchorPane solarPanelPane;
+ @FXML
+ private Button displayVeganMealButton;
+ @FXML
+ private Button displayBikeButton;
+ @FXML
+ private Button displayTemperatureButton;
+ @FXML
+ private Button displaySolarPanelButton;
+
+ @FXML
+ private Button addVeganMealButton;
+ @FXML
+ private Button addBikeButton;
+ @FXML
+ private Button addTemperatureButton;
+ @FXML
+ private Button addSolarPanelsButton;
+ @FXML
+ private Slider bikeSlider;
+ @FXML
+ private Label bikeLabel;
+ @FXML
+ private Slider temperatureSlider;
+ @FXML
+ private Label temperatureLabel;
+ @FXML
+ private Slider solarPanelsSlider;
+ @FXML
+ private Label solarPanelsLabel;
+
+ /**
+ * initializes the sliders and labels before loading.
+ * sets the labels to display the outputs of the designated sliders.
+ */
+ public void initialize() {
+ coupleSliderToLabel(bikeSlider, bikeLabel, " km", false);
+ coupleSliderToLabel(temperatureSlider, temperatureLabel, " Degrees", true);
+ coupleSliderToLabel(solarPanelsSlider, solarPanelsLabel, "", true);
+
+ }
+
+ /**
+ * Sets the label to display the value of the designated slider.
+ * sets the text to be displayed after the value of the slider.
+ * sets whether the slider should snap to ticks
+ * @param slider the slider to read the value from
+ * @param label the label to display the value of the slider
+ * @param string the string to be placed after the outputted value of the slider
+ * @param snapToTicks whether the slider should snap to ticks or not
+ */
+ public void coupleSliderToLabel(Slider slider, Label label, String string,
+ boolean snapToTicks) {
+ slider.setSnapToTicks(snapToTicks);
+ slider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ label.setText(newValue.intValue() + string);
+ }
+ });
+ }
+
+ /**
+ * displays the vegetarian meal section.
+ * @param event the click of the designated button
+ */
+ public void displayVeganMeal(ActionEvent event) {
+ // System.out.println("display vm");
+ veganMealPane.setVisible(true);
+ bikePane.setVisible(false);
+ temperaturePane.setVisible(false);
+ solarPanelPane.setVisible(false);
+ }
+
+ /**
+ * displays the bike section.
+ * @param event the click of the designated button
+ */
+ public void displayBike(ActionEvent event) {
+ // System.out.println("display b");
+ veganMealPane.setVisible(false);
+ bikePane.setVisible(true);
+ temperaturePane.setVisible(false);
+ solarPanelPane.setVisible(false);
+ }
+
+ /**
+ * displays the temperature section.
+ * @param event the click of the designated button
+ */
+ public void displayTemperature(ActionEvent event) {
+ // System.out.println("display t");
+ veganMealPane.setVisible(false);
+ bikePane.setVisible(false);
+ temperaturePane.setVisible(true);
+ solarPanelPane.setVisible(false);
+ }
+
+ /**
+ * displays the solar panels section.
+ * @param event the click of the designated button
+ */
+ public void displaySolarPanel(ActionEvent event) {
+ // System.out.println("display sp");
+ veganMealPane.setVisible(false);
+ bikePane.setVisible(false);
+ temperaturePane.setVisible(false);
+ solarPanelPane.setVisible(true);
+ }
+}
diff --git a/src/Client/src/main/java/greenify/client/controller/FriendController.java b/src/Client/src/main/java/greenify/client/controller/FriendController.java
new file mode 100644
index 0000000..a623de5
--- /dev/null
+++ b/src/Client/src/main/java/greenify/client/controller/FriendController.java
@@ -0,0 +1,58 @@
+package greenify.client.controller;
+
+import greenify.client.rest.UserService;
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.scene.control.Alert;
+import javafx.scene.control.Button;
+import javafx.scene.control.TextField;
+import javafx.stage.Stage;
+import javafx.stage.Window;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class FriendController {
+ @Autowired
+ UserService userService;
+
+ @FXML
+ private Button addButton;
+ @FXML
+ private TextField userNameText;
+
+ /**
+ * Signs up the user.
+ * @param event the click of the sign up button
+ */
+ @FXML
+ public void addFriend(ActionEvent event) throws InterruptedException {
+ //set the window to the current window (for displaying the alerts)
+ Window owner = addButton.getScene().getWindow();
+ //check if the username field is empty
+ if (userNameText.getText().isEmpty()) {
+ //if so, display an alert
+ UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
+ "Please enter a username!");
+ return;
+ } else if (userNameText.getText().equals(userService.currentUser.getName())) {
+ UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
+ "Cannot add yourself as a friend!");
+ return;
+ } else if (userService.getFriendNames(userService.currentUser.getName())
+ .contains(userNameText.getText())) {
+ UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
+ "Cannot add a friend twice!");
+ return;
+ } else if (!userService.getAllUsers().contains(userNameText.getText())) {
+ UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
+ "The user does not exist!");
+ return;
+ }
+ //add friend to the current user
+ userService.addFriend(userService.currentUser.getName(), userNameText.getText());
+ //close the register window after the user has entered all the credentials
+ Stage current = (Stage) owner;
+ current.close();
+ }
+}
diff --git a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java
index c3d3bb4..11cb71f 100644
--- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java
+++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java
@@ -1,20 +1,37 @@
package greenify.client.controller;
+import greenify.client.Application;
import greenify.client.rest.UserService;
+import javafx.animation.Interpolator;
+import javafx.animation.KeyFrame;
+import javafx.animation.KeyValue;
+import javafx.animation.Timeline;
import javafx.animation.TranslateTransition;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Node;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
+import javafx.scene.control.ScrollPane;
+import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
+import javafx.scene.layout.AnchorPane;
+import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
+import java.io.IOException;
+import java.text.DecimalFormat;
import java.util.concurrent.TimeUnit;
/**
@@ -26,6 +43,123 @@ public class RegisterWindowController {
@Autowired
UserService userService;
+ @Autowired
+ DashBoardController controller;
+
+ //navigation panes
+ @FXML
+ private AnchorPane getStartedPane;
+ @FXML
+ private AnchorPane travelPane;
+ @FXML
+ private AnchorPane homePane;
+ @FXML
+ private ScrollPane foodPane;
+ @FXML
+ private AnchorPane shoppingPane;
+
+ //'get started' pane
+ @FXML
+ private Slider peopleInHouseholdSlider;
+ @FXML
+ private Label peopleInHouseHoldLabel;
+ @FXML
+ private Slider annualIncomeSlider;
+ @FXML
+ private Label annualIncomeLabel;
+ @FXML
+ private Button saveButton;
+
+ //travel pane
+ @FXML
+ private TextField publicTransitField;
+ @FXML
+ private TextField airplaneTravelField;
+ @FXML
+ private TextField carTravelGasolineField;
+ @FXML
+ private Slider carTravelGasolineSlider;
+ @FXML
+ private Label carTravelGasolineLabel;
+ @FXML
+ private TextField carTravelDieselField;
+ @FXML
+ private Slider carTravelDieselSlider;
+ @FXML
+ private Label carTravelDieselLabel;
+ @FXML
+ private TextField carTravelElectricField;
+ @FXML
+ private Slider carTravelElectricSlider;
+ @FXML
+ private Label carTravelElectricLabel;
+
+ //home pane
+ @FXML
+ private TextField electricityField;
+ @FXML
+ private Slider cleanEnergyPurchasedSlider;
+ @FXML
+ private Label cleanEnergyPurchasedLabel;
+ @FXML
+ private TextField naturalGasField;
+ @FXML
+ private TextField heatingOilField;
+ @FXML
+ private TextField livingSpaceField;
+ @FXML
+ private Slider waterUsageSlider;
+ @FXML
+ private Label waterUsageLabel;
+
+ //food pane
+ @FXML
+ private Slider meatFishEggsSlider;
+ @FXML
+ private Label meatFishEggsLabel;
+ @FXML
+ private Slider grainsBakedGoodsSlider;
+ @FXML
+ private Label grainsBakedGoodsLabel;
+ @FXML
+ private Slider dairySlider;
+ @FXML
+ private Label dairyLabel;
+ @FXML
+ private Slider fruitsVegetablesSlider;
+ @FXML
+ private Label fruitsVegetablesLabel;
+ @FXML
+ private Slider snacksDrinksSlider;
+ @FXML
+ private Label snacksDrinksLabel;
+
+ //shopping pane
+ @FXML
+ private Text goodsField;
+ @FXML
+ private Text servicesField;
+ @FXML
+ private Slider goodsSlider;
+ @FXML
+ private Label goodsLabel;
+ @FXML
+ private Slider servicesSlider;
+ @FXML
+ private Label servicesLabel;
+
+ //extra pane
+ @FXML
+ private AnchorPane extraPane;
+ @FXML
+ private CheckBox localProduceCheckbox;
+ @FXML
+ private CheckBox bikeCheckbox;
+ @FXML
+ private CheckBox temperatureCheckbox;
+ @FXML
+ private CheckBox solarPanelsCheckbox;
+
@FXML
private TextField userNameText;
@FXML
@@ -42,14 +176,10 @@ public class RegisterWindowController {
* @throws InterruptedException exception when interrupted
*/
public void initialize() throws InterruptedException {
- // PathTransition pathTransUName = new PathTransition(Duration.millis(1100),
- // uNamePathLine, userNameText);
- // pathTransUName.play();
addSlideAnimation(1100, userNameText, -300);
addSlideAnimation(1100, passwordField, 300);
TimeUnit.MILLISECONDS.sleep(300);
addSlideAnimation(1100, passwordField2, -420);
-
}
/**
@@ -70,7 +200,7 @@ public class RegisterWindowController {
* @param event the click of the sign up button
*/
@FXML
- public void handleSignUpButton(ActionEvent event) {
+ public void handleSignUpButton(ActionEvent event) throws IOException {
//set the window to the current window (for displaying the alerts)
Window owner = signUpButton.getScene().getWindow();
//check if the username field is empty
@@ -99,9 +229,353 @@ public class RegisterWindowController {
//register the user with the provided username and password
userService.registerUser(userNameText.getText(), passwordField.getText());
-
//close the register window after the user has entered all the credentials
Stage current = (Stage) owner;
current.close();
+
+ Parent calc = Application.load(this.getClass().getClassLoader()
+ .getResource("fxml/FirstCalculator.fxml"));
+ Scene scene = new Scene(calc);
+ scene.getStylesheets().add(getClass().getClassLoader()
+ .getResource("stylesheets/calculatorStyle.css").toExternalForm());
+ Stage calcStage = new Stage();
+
+ calcStage.setScene(scene);
+ calcStage.setTitle("Calculate CO2 footprint - " + userService.currentUser.getName());
+ calcStage.show();
+
+ peopleInHouseholdSlider.setSnapToTicks(true);
+ //add listener to slider for amount of people in household
+ peopleInHouseholdSlider.valueProperty().addListener(new ChangeListener() {
+
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ peopleInHouseHoldLabel.setText("" + newValue.intValue());
+ }
+ });
+
+ //add listener to slider for annual income
+ annualIncomeSlider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ annualIncomeLabel.setText("" + (newValue.intValue() * 1000));
+ }
+ });
+
+ addSliderListenerCarUsage(carTravelGasolineSlider, carTravelGasolineLabel, " mpg");
+ addSliderListenerCarUsage(carTravelDieselSlider, carTravelDieselLabel, " mpg");
+ addSliderListenerCarUsage(carTravelElectricSlider, carTravelElectricLabel, " mpge");
+
+ cleanEnergyPurchasedSlider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ cleanEnergyPurchasedLabel.setText(newValue.intValue() + " %");
+ }
+ });
+
+ waterUsageSlider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ waterUsageLabel.setText(newValue.intValue() + "% of similar households");
+ }
+ });
+
+ addSliderListenerDailyServing(meatFishEggsSlider, meatFishEggsLabel);
+ addSliderListenerDailyServing(grainsBakedGoodsSlider, grainsBakedGoodsLabel);
+ addSliderListenerDailyServing(dairySlider, dairyLabel);
+ addSliderListenerDailyServing(fruitsVegetablesSlider, fruitsVegetablesLabel);
+ addSliderListenerDailyServing(snacksDrinksSlider, snacksDrinksLabel);
+
+ addSliderListenerGoodsServices(goodsSlider, goodsLabel);
+ addSliderListenerGoodsServices(servicesSlider, servicesLabel);
+ }
+
+ /**
+ * adds the listener to the given slider and displays it's output on a given label.
+ * @param slider the slider to attach the listener to.
+ * @param label the label to display the slider output on.
+ */
+ private void addSliderListenerCarUsage(Slider slider, Label label, String unit) {
+ slider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ label.setText(newValue.intValue() + unit);
+ }
+ });
+ }
+
+ private void addSliderListenerDailyServing(Slider slider, Label label) {
+ DecimalFormat df = new DecimalFormat("0.0");
+ slider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ label.setText(df.format(newValue.doubleValue()) + " daily servings per person");
+ }
+ });
+ }
+
+ private void addSliderListenerGoodsServices(Slider slider, Label label) {
+ slider.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Number> observable,
+ Number oldValue, Number newValue) {
+ label.setText(newValue.intValue() + "€ / month");
+ }
+ });
+ }
+
+ private void addSlideInAnimation(Node node) {
+ Timeline timeline = new Timeline();
+ KeyValue keyValue = new KeyValue(node.translateXProperty(), 0, Interpolator.EASE_OUT);
+ KeyFrame keyFrame = new KeyFrame(Duration.millis(600), keyValue);
+ timeline.getKeyFrames().add(keyFrame);
+ timeline.play();
+ }
+
+ /**
+ * displays the 'get started' section of the calculator.
+ * Activated when the designated button (navigation button) is clicked
+ * @param event the click of the button
+ */
+ @SuppressWarnings("Duplicates")
+ public void displayGetStarted(ActionEvent event) {
+ getStartedPane.setVisible(true);
+ travelPane.setVisible(false);
+ homePane.setVisible(false);
+ foodPane.setVisible(false);
+ shoppingPane.setVisible(false);
+ extraPane.setVisible(false);
+ }
+
+ /**
+ * displays the 'travel' section of the calculator.
+ * Activated when the designated button (navigation button) is clicked
+ * @param event the click of the button
+ */
+ @SuppressWarnings("Duplicates")
+ public void displayTravel(ActionEvent event) {
+ addSlideInAnimation(travelPane);
+ getStartedPane.setVisible(false);
+ travelPane.setVisible(true);
+ homePane.setVisible(false);
+ foodPane.setVisible(false);
+ shoppingPane.setVisible(false);
+ extraPane.setVisible(false);
+
+ }
+
+ /**
+ * displays the 'home' section of the calculator.
+ * Activated when the designated button (navigation button) is clicked
+ * @param event the click of the button
+ */
+ @SuppressWarnings("Duplicates")
+ public void displayHome(ActionEvent event) {
+ getStartedPane.setVisible(false);
+ travelPane.setVisible(false);
+ homePane.setVisible(true);
+ foodPane.setVisible(false);
+ shoppingPane.setVisible(false);
+ extraPane.setVisible(false);
+ }
+
+ /**
+ * displays the 'food' section of the calculator.
+ * Activated when the designated button (navigation button) is clicked
+ * @param event the click of the button
+ */
+ @SuppressWarnings("Duplicates")
+ public void displayFood(ActionEvent event) {
+ getStartedPane.setVisible(false);
+ travelPane.setVisible(false);
+ homePane.setVisible(false);
+ foodPane.setVisible(true);
+ shoppingPane.setVisible(false);
+ extraPane.setVisible(false);
+ }
+
+ /**
+ * displays the 'shopping' section of the calculator.
+ * Activated when the designated button (navigation button) is clicked
+ * @param event the click of the button
+ */
+ @SuppressWarnings("Duplicates")
+ public void displayShopping(ActionEvent event) {
+ getStartedPane.setVisible(false);
+ travelPane.setVisible(false);
+ homePane.setVisible(false);
+ foodPane.setVisible(false);
+ shoppingPane.setVisible(true);
+ extraPane.setVisible(false);
+ }
+
+ /**
+ * displays the 'Extra' section of the calculator.
+ * Activated when the designated button (navigation button) is clicked
+ * @param event the click of the designated button
+ */
+ @SuppressWarnings("Duplicates")
+ public void displayExtra(ActionEvent event) {
+ getStartedPane.setVisible(false);
+ travelPane.setVisible(false);
+ homePane.setVisible(false);
+ foodPane.setVisible(false);
+ shoppingPane.setVisible(false);
+ extraPane.setVisible(true);
+
+ }
+
+ /**
+ * The method saves the calculation.
+ * @param event user clicks to button
+ */
+ @SuppressWarnings("Duplicates")
+ public void saveCalc(ActionEvent event) throws InterruptedException {
+ getStartedPane.setVisible(false);
+ travelPane.setVisible(false);
+ homePane.setVisible(false);
+ foodPane.setVisible(false);
+ shoppingPane.setVisible(false);
+ if (!annualIncomeLabel.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(), "input_income",
+ annualIncomeLabel.getText());
+ }
+ if (!peopleInHouseHoldLabel.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(), "input_size",
+ peopleInHouseHoldLabel.getText());
+ }
+ if (!publicTransitField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_publictrans",
+ publicTransitField.getText());
+ }
+ if (!airplaneTravelField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_airtotal",
+ airplaneTravelField.getText());
+ }
+ if (!carTravelGasolineField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_miles1",
+ carTravelGasolineField.getText());
+ }
+ if (!carTravelGasolineLabel.getText().replace(" mpg", "").equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_mpg1",
+ carTravelGasolineLabel.getText().replace(" mpg", ""));
+ }
+ if (!carTravelDieselField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_miles2",
+ carTravelDieselField.getText());
+ }
+ if (!carTravelDieselLabel.getText().replace(" mpg", "").equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_mpg2",
+ carTravelDieselLabel.getText().replace(" mpg", ""));
+ }
+ if (!carTravelElectricField.getText().equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "input_footprint_transportation_miles3",
+ carTravelElectricField.getText());
+ }
+ if (!carTravelElectricLabel.getText().replace(" mpge", "").equals("0")) {
+ userService.updateInput(userService.currentUser.getName(),
+ "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();
}
}
diff --git a/src/Client/src/main/resources/fxml/AddFriend.fxml b/src/Client/src/main/resources/fxml/AddFriend.fxml
new file mode 100644
index 0000000..018a0ed
--- /dev/null
+++ b/src/Client/src/main/resources/fxml/AddFriend.fxml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Client/src/main/resources/fxml/FirstCalculator.fxml b/src/Client/src/main/resources/fxml/FirstCalculator.fxml
new file mode 100644
index 0000000..71554f6
--- /dev/null
+++ b/src/Client/src/main/resources/fxml/FirstCalculator.fxml
@@ -0,0 +1,632 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Client/src/main/resources/fxml/calculator.fxml b/src/Client/src/main/resources/fxml/calculator.fxml
index f019cd9..46f86a4 100644
--- a/src/Client/src/main/resources/fxml/calculator.fxml
+++ b/src/Client/src/main/resources/fxml/calculator.fxml
@@ -1,16 +1,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -153,14 +270,20 @@
-
+
+
+
+
-
-
+
+
+
+
+
@@ -169,7 +292,7 @@
-
+
@@ -179,11 +302,331 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
diff --git a/src/Client/src/main/resources/fxml/dashboard.fxml b/src/Client/src/main/resources/fxml/dashboard.fxml
index 26ab6c3..5ade608 100644
--- a/src/Client/src/main/resources/fxml/dashboard.fxml
+++ b/src/Client/src/main/resources/fxml/dashboard.fxml
@@ -1,5 +1,12 @@
+
+
+
+
+
+
+
diff --git a/src/Client/src/main/resources/fxml/extraActivities.fxml b/src/Client/src/main/resources/fxml/extraActivities.fxml
new file mode 100644
index 0000000..d1ab289
--- /dev/null
+++ b/src/Client/src/main/resources/fxml/extraActivities.fxml
@@ -0,0 +1,188 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Client/src/main/resources/icons/friend.png b/src/Client/src/main/resources/icons/friend.png
new file mode 100644
index 0000000..98490e8
Binary files /dev/null and b/src/Client/src/main/resources/icons/friend.png differ
diff --git a/src/Client/src/main/resources/icons/friends.png b/src/Client/src/main/resources/icons/friends.png
new file mode 100644
index 0000000..516e7e5
Binary files /dev/null and b/src/Client/src/main/resources/icons/friends.png differ
diff --git a/src/Client/src/main/resources/icons/grass.png b/src/Client/src/main/resources/icons/grass.png
new file mode 100644
index 0000000..5d5ad30
Binary files /dev/null and b/src/Client/src/main/resources/icons/grass.png differ
diff --git a/src/Client/src/main/resources/icons/icons8-bicycle-filled-100.png b/src/Client/src/main/resources/icons/icons8-bicycle-filled-100.png
new file mode 100644
index 0000000..8fd71e4
Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-bicycle-filled-100.png differ
diff --git a/src/Client/src/main/resources/icons/icons8-potted-plant-100.png b/src/Client/src/main/resources/icons/icons8-potted-plant-100.png
new file mode 100644
index 0000000..38a5b2f
Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-potted-plant-100.png differ
diff --git a/src/Client/src/main/resources/icons/icons8-potted-plant-50.png b/src/Client/src/main/resources/icons/icons8-potted-plant-50.png
new file mode 100644
index 0000000..750f9b6
Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-potted-plant-50.png differ
diff --git a/src/Client/src/main/resources/icons/icons8-solar-panel-filled-100.png b/src/Client/src/main/resources/icons/icons8-solar-panel-filled-100.png
new file mode 100644
index 0000000..58fb479
Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-solar-panel-filled-100.png differ
diff --git a/src/Client/src/main/resources/icons/icons8-temperature-inside-64.png b/src/Client/src/main/resources/icons/icons8-temperature-inside-64.png
new file mode 100644
index 0000000..d548a77
Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-temperature-inside-64.png differ
diff --git a/src/Client/src/main/resources/icons/icons8-vegan-food-100.png b/src/Client/src/main/resources/icons/icons8-vegan-food-100.png
new file mode 100644
index 0000000..83f766b
Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-vegan-food-100.png differ
diff --git a/src/Client/src/main/resources/icons/leaficon.png b/src/Client/src/main/resources/icons/leaficon.png
new file mode 100644
index 0000000..2676b75
Binary files /dev/null and b/src/Client/src/main/resources/icons/leaficon.png differ
diff --git a/src/Client/src/main/resources/stylesheets/calculatorStyle.css b/src/Client/src/main/resources/stylesheets/calculatorStyle.css
index a60f95f..1877abb 100644
--- a/src/Client/src/main/resources/stylesheets/calculatorStyle.css
+++ b/src/Client/src/main/resources/stylesheets/calculatorStyle.css
@@ -14,6 +14,9 @@
-fx-font-size: 16px;
-fx-font-weight: regular;
}
+#calculatorTabs #saveButton:hover {
+ -fx-background-color: #9ec19c;
+}
.nextButton {
-fx-background-color: #89a888;
@@ -26,7 +29,6 @@
.slider {
-show-value-on-interaction: true;
- -fx-text-fill: red;
}
.km-yearBox {
@@ -36,6 +38,38 @@
-fx-padding: 0 0 0 3px;
}
+.km-indicator {
+ -fx-background-color: #89a888;
+ -fx-background-radius: 5px;
+ -fx-border-radius: 5px;
+}
+
+.slider .track {
+ -fx-background-color: #d3d3d3;
+}
+
+.slider .thumb {
+ -fx-background-color: transparent;
+ -fx-background-image: url('../icons/leaficon.png');
+ -fx-padding: 12;
+}
+
+.check-box .box {
+ -fx-background-color: #d7d8d6;
+ -fx-border-color: transparent;
+ -fx-border-radius: 6px;
+}
+
+.check-box:selected .mark {
+ -fx-background-color: #ebedea;
+}
+
+.check-box:selected .box {
+ -fx-background-color: #91ad83;
+ -fx-border-radius: 6px;
+ -fx-border-color: transparent;
+}
+
diff --git a/src/Client/src/main/resources/stylesheets/dashboardStyle.css b/src/Client/src/main/resources/stylesheets/dashboardStyle.css
index eb074d6..f9d80a2 100644
--- a/src/Client/src/main/resources/stylesheets/dashboardStyle.css
+++ b/src/Client/src/main/resources/stylesheets/dashboardStyle.css
@@ -6,7 +6,7 @@
.root {
-fx-background-color: #f9fffb;
/*-fx-font-family: "Designio Regular";*/
- -fx-font-family: Corbel; /*this doesn't work for some reason*/
+ /*-fx-font-family: Corbel; !*this doesn't work for some reason*!*/
}
#dashboardButton {
@@ -58,13 +58,31 @@
}
/*friends table*/
-#friendsTable .column-header {
+.table-view .column-header {
/*-fx-background-color: linear-gradient(#4b7a3d, #588c58);*/
-fx-background-color: #5a635c;
+
}
-#friendsTable .column-header .label {
+.table-view .column-header .label {
-fx-text-fill: #d4d6d4;
+ -fx-font-size: 18px;
+}
+
+.table-view .table-cell {
+ -fx-font-size: 17px;
+}
+
+.table-row-cell {
+ -fx-background-color: #c4f2cb;
+}
+
+.table-row-cell:odd {
+ -fx-background-color: #b7e2c2;
+}
+
+.activityField {
+ -fx-font-size: 14px;
}
diff --git a/src/Client/src/main/resources/stylesheets/extraActivitiesStyle.css b/src/Client/src/main/resources/stylesheets/extraActivitiesStyle.css
new file mode 100644
index 0000000..e30c77a
--- /dev/null
+++ b/src/Client/src/main/resources/stylesheets/extraActivitiesStyle.css
@@ -0,0 +1,19 @@
+.navButton {
+ -fx-background-color: #6a7a6d;
+}
+
+.slider .track {
+ -fx-background-color: #d3d3d3;
+}
+
+.slider .thumb {
+ -fx-background-color: transparent;
+ -fx-background-image: url('../icons/leaficon.png');
+ -fx-padding: 12;
+}
+
+.textHolder {
+ -fx-background-color: #89a888;
+ -fx-background-radius: 5px;
+ -fx-border-radius: 5px;
+}
\ No newline at end of file
diff --git a/src/Client/src/test/java/HintsTest.java b/src/Client/src/test/java/HintsTest.java
new file mode 100644
index 0000000..c0e2442
--- /dev/null
+++ b/src/Client/src/test/java/HintsTest.java
@@ -0,0 +1,29 @@
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import greenify.client.Hints;
+import org.junit.Test;
+
+public class HintsTest {
+ @Test
+ public void initHintsTest() {
+ Hints test = new Hints();
+ assertFalse(test.hints.isEmpty());
+ }
+
+ @Test
+ public void hintsContainsTest() {
+ Hints test = new Hints();
+ assertTrue(test.hints.contains("27,000 trees are cut down "
+ + "each day so we can have toilet paper."));
+ }
+
+ @Test
+ public void randomHintTest() {
+ Hints test = new Hints();
+ String random = test.randomHint();
+ assertTrue(test.hints.contains(random));
+ }
+}
+
+
diff --git a/src/Server/src/main/java/greenify/server/rest/UserController.java b/src/Server/src/main/java/greenify/server/rest/UserController.java
index d60f933..34448f6 100644
--- a/src/Server/src/main/java/greenify/server/rest/UserController.java
+++ b/src/Server/src/main/java/greenify/server/rest/UserController.java
@@ -62,8 +62,8 @@ public class UserController {
*/
@RequestMapping("/setExtraInput")
public void setExtraInput(@RequestParam(value = "name") String name,
- @RequestParam(value = "inputName") String inputName,
- @RequestParam(value = "value") Boolean value) {
+ @RequestParam(value = "inputName") String inputName,
+ @RequestParam(value = "value") Boolean value) {
userService.setExtraInput(name, inputName, value);
}
@@ -186,3 +186,4 @@ public class UserController {
return userService.getAchievements(name);
}
}
+
diff --git a/src/Server/src/main/java/greenify/server/service/CalculatorService.java b/src/Server/src/main/java/greenify/server/service/CalculatorService.java
index fa4294d..4258c3b 100644
--- a/src/Server/src/main/java/greenify/server/service/CalculatorService.java
+++ b/src/Server/src/main/java/greenify/server/service/CalculatorService.java
@@ -72,7 +72,21 @@ public class CalculatorService {
* @return the footprint of the user
*/
public Float calculateFootprint(User user) {
- return invokeExternalService(user.getFootPrintInputs());
+ Float footprint = invokeExternalService(user.getFootPrintInputs());
+ addExtras(user);
+ return footprint;
+ }
+
+ public void addExtras(User user) {
+ if (user.getExtraInputs().get("local_produce")) {
+ user.setFootPrint(user.getFootPrint() - 2);
+ } else if (user.getExtraInputs().get("bike")) {
+ user.setFootPrint(user.getFootPrint() - 2);
+ } else if (user.getExtraInputs().get("temperature")) {
+ user.setFootPrint(user.getFootPrint() - 2);
+ } else if (user.getExtraInputs().get("solar_panels")) {
+ user.setFootPrint(user.getFootPrint() - 2);
+ }
}
}
diff --git a/src/Server/src/test/java/greenify/server/service/CalculatorServiceTest.java b/src/Server/src/test/java/greenify/server/service/CalculatorServiceTest.java
index b0820e0..d252949 100644
--- a/src/Server/src/test/java/greenify/server/service/CalculatorServiceTest.java
+++ b/src/Server/src/test/java/greenify/server/service/CalculatorServiceTest.java
@@ -92,6 +92,29 @@ public class CalculatorServiceTest {
Assert.assertEquals(new Float(19.259982), footPrint);
}
+ @Test
+ public void addExtrasTest() throws URISyntaxException {
+ User user = new User(1L,"greenify", "password");
+ Map map = new HashMap() {{
+ put("local_produce", false);
+ put("bike", false);
+ put("temperature", false);
+ put("solar_panels", false);
+ }};
+ user.setExtraInputs(map);
+ user.setFootPrint(50f);
+ Map secondMap = new HashMap() {{
+ put("local_produce", true);
+ put("bike", true);
+ put("temperature", true);
+ put("solar_panels", true);
+ }};
+ user.setExtraInputs(secondMap);
+ calculatorService.addExtras(user);
+ mockServer.verify();
+ Assert.assertEquals(new Float(48f), user.getFootPrint());
+ }
+
@Test
public void invokeExternalServiceTest() {
CalculatorService service = new CalculatorService();