Skip to content

Commit

Permalink
Fix: Fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyah committed May 25, 2026
1 parent 3fcd0a0 commit 8bc2c8b
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -88,10 +88,10 @@ public void start(final Stage stage) throws Exception {
ViewManager viewManager = new ViewManager(stage, eventManager);

List<Stock> 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"));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -72,6 +74,11 @@ public SaveGame(final String name,
final int week,
final List<OwnedShareData> ownedShares,
final List<TransactionData> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,4 @@ public enum EventType implements EventChannel {
* but most listeners don't inspect it.</p>
* */
STATE_RESET;

/**
* {@inheritDoc}
* */
@Override
public String getName() {
return this.name();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public <T> void handleEvent(final EventData<T> 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);
Expand Down
43 changes: 43 additions & 0 deletions src/main/resources/saves/Tommy.json
Original file line number Diff line number Diff line change
@@ -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 }
]
}

0 comments on commit 8bc2c8b

Please sign in to comment.