diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
index cec044e..52f90fd 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
@@ -4,10 +4,10 @@
import edu.ntnu.idi.idatt2003.g40.mappe.model.Player;
import edu.ntnu.idi.idatt2003.g40.mappe.model.SaveGame;
import edu.ntnu.idi.idatt2003.g40.mappe.model.Stock;
-import edu.ntnu.idi.idatt2003.g40.mappe.service.FileConverter;
-import edu.ntnu.idi.idatt2003.g40.mappe.service.FileParser;
import edu.ntnu.idi.idatt2003.g40.mappe.service.GameStateLoader;
import edu.ntnu.idi.idatt2003.g40.mappe.service.SaveGameService;
+import edu.ntnu.idi.idatt2003.g40.mappe.service.StockFileManager;
+import edu.ntnu.idi.idatt2003.g40.mappe.service.StockFileParser;
import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager;
import edu.ntnu.idi.idatt2003.g40.mappe.utils.ConfigValues;
import edu.ntnu.idi.idatt2003.g40.mappe.utils.ThemeManager;
@@ -88,10 +88,10 @@ public void start(final Stage stage) throws Exception {
ViewManager viewManager = new ViewManager(stage, eventManager);
List stocksInFile;
- FileParser parser1 = new FileParser("/sp500.csv");
+ StockFileManager fileManager = new StockFileManager("src/main/resources/sp500.csv");
- FileConverter converter1 = new FileConverter();
- stocksInFile = converter1.getStocksFromStrings(parser1.readFile());
+ StockFileParser fileParser = new StockFileParser();
+ stocksInFile = fileParser.getStocksFromStrings(fileManager.readFile());
Exchange exchange = new Exchange("Exchange", stocksInFile);
Player player = new Player("Player 1", new BigDecimal("10000"));
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/model/SaveGame.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/model/SaveGame.java
index 9dc97ec..ac406fb 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/model/SaveGame.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/model/SaveGame.java
@@ -1,5 +1,7 @@
package edu.ntnu.idi.idatt2003.g40.mappe.model;
+import edu.ntnu.idi.idatt2003.g40.mappe.utils.Validator;
+
import java.util.Collections;
import java.util.List;
@@ -72,6 +74,11 @@ public SaveGame(final String name,
final int week,
final List ownedShares,
final List transactions) {
+ if (!Validator.NOT_EMPTY.isValid(name)
+ || balance <= 0
+ || startingCapital <= 0) {
+ throw new IllegalArgumentException("Invalid Save configuration!");
+ }
this.name = name;
this.balance = balance;
this.startingCapital = startingCapital;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/service/event/EventType.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/service/event/EventType.java
index 47aba89..825e9bc 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/service/event/EventType.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/service/event/EventType.java
@@ -91,12 +91,4 @@ public enum EventType implements EventChannel {
* but most listeners don't inspect it.
* */
STATE_RESET;
-
- /**
- * {@inheritDoc}
- * */
- @Override
- public String getName() {
- return this.name();
- }
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/dashboard/DashBoardController.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/dashboard/DashBoardController.java
index 83648ed..3165949 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/dashboard/DashBoardController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/dashboard/DashBoardController.java
@@ -234,7 +234,7 @@ public void handleEvent(final EventData data) {
if (!stockList.isEmpty()) {
Stock first = stockList.getFirst();
BigDecimal owned = player.getPortfolio()
- .getTotalSharesBySymbol(first.getSymbol());
+ .getTotalShareQuantityBySymbol(first.getSymbol());
getViewElement().setCurrentStock(first, owned.floatValue());
}
getViewElement().updateGraph(selectedTimeRange);
diff --git a/src/main/resources/saves/Tommy.json b/src/main/resources/saves/Tommy.json
new file mode 100644
index 0000000..90979ce
--- /dev/null
+++ b/src/main/resources/saves/Tommy.json
@@ -0,0 +1,43 @@
+{
+ "name": "Tommy",
+ "balance": 93987.07495,
+ "startingCapital": 100000.0,
+ "stockDataPath": "C:\\Users\\tohja\\Desktop\\StockData1.txt",
+ "week": 18,
+ "ownedShares": [
+ { "symbol": "NVDA", "quantity": 31.0, "purchasePrice": 191.27 }
+ ],
+ "transactions": [
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 191.27, "week": 1 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 },
+ { "type": "PURCHASE", "symbol": "NVDA", "quantity": 1.0, "price": 195.74, "week": 4 }
+ ]
+}