-
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.
Created StockFileWriter interface and moved csv write to its own file…
… to open up for additional formats in the future
- Loading branch information
Nikollai
committed
Apr 12, 2026
1 parent
84c1a03
commit ea0abe1
Showing
3 changed files
with
43 additions
and
34 deletions.
There are no files selected for viewing
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,35 @@ | ||
| package millions.controller; | ||
|
|
||
| import millions.model.Stock; | ||
|
|
||
| import java.io.FileWriter; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class CSVStockFileWriter implements StockFileWriter { | ||
| List<Stock> stocks; | ||
| String finalString; | ||
|
|
||
| public CSVStockFileWriter(List<Stock> stocks) { | ||
| this.stocks = stocks; | ||
| } | ||
|
|
||
| @Override | ||
| public void formatString() { | ||
| StringBuilder builder = new StringBuilder(); | ||
| stocks.forEach(stock -> { | ||
| builder.append(stock.getSymbol()); | ||
| builder.append(","); | ||
| builder.append(stock.getCompany()); | ||
| builder.append(","); | ||
| builder.append(stock.getLatestPriceChange().toString()); | ||
| }); | ||
| this.finalString = builder.toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean write(){ | ||
| // TODO: handle file creation/file selection when writing to file | ||
| return false; | ||
| } | ||
| } |
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,8 @@ | ||
| package millions.controller; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface StockFileWriter { | ||
| public void formatString(); | ||
| public boolean write(); | ||
| } |
34 changes: 0 additions & 34 deletions
34
src/main/java/millions/controller/StockInformationWriter.java
This file was deleted.
Oops, something went wrong.