-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from einaskoi/einar/stockApp
Einar/stock app
- Loading branch information
Showing
7 changed files
with
112 additions
and
7 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...ain/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppController/StockAppController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppController; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.gruppe42.Controller.MarketController; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.View.Popups.StockPopup; | ||
|
|
||
| public class StockAppController { | ||
| private MarketController marketController; | ||
|
|
||
| public StockAppController(StockPopup stockPopup) { | ||
| marketController = new MarketController(); | ||
|
|
||
| stockPopup.getStockList().getItems().addAll(marketController.getMarket()); | ||
|
|
||
| stockPopup.getSearchField().textProperty().addListener((obs, old, newValue) -> { | ||
| stockPopup.getStockList().getItems().setAll(marketController.getMarket(newValue)); | ||
| }); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/MarketController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Controller; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.StockFileHandler; | ||
|
|
||
| import java.nio.file.Path; | ||
| import java.util.List; | ||
|
|
||
| public class MarketController { | ||
|
|
||
| private List<Stock> market; | ||
|
|
||
| public MarketController() { | ||
| try { | ||
| Path path = Path.of(getClass().getClassLoader().getResource("stocks.csv").toURI()); | ||
| market = StockFileHandler.readFromFile(path); | ||
| } catch (Exception e) { | ||
| System.out.println("File not found"); | ||
| } | ||
| } | ||
|
|
||
| public List<Stock> getMarket() { | ||
| return market; | ||
| } | ||
|
|
||
| public List<Stock> getMarket(String searchTerm) { | ||
| return market.stream().filter(stock -> stock.getCompany().toLowerCase().contains(searchTerm.toLowerCase())).toList(); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Companies by Market Cap | ||
| # Ticker,Name,Price | ||
|
|
||
| BAN,Banana Inc.,191.27 | ||
| APL,Apple Inc.,276.43 | ||
| TIR,Tire Inc.,404.68 | ||
| OIL,Oil Inc.,204.62 | ||
| SPC,Space Org.,311.20 | ||
| WND,Turbine Inc.,311.62 | ||
| NUC,Nuclear Inc.,343.35 | ||
| CAR,Car Inc.,426.52 | ||
| HYD,Hydro Inc.,501.05 | ||
| TIP,Q-tip Inc.,128.75 | ||
| TED,Teddy Bear Inc.,1014.43 | ||
| UNI,NTNU Org.,311.14 | ||
| COM,Communication Org.,155.28 | ||
| MON,Monsters Inc.,329.54 | ||
| AIR,Plane Inc.,240.70 | ||
| ATB,Bus Inc.,539.52 |