Skip to content

Commit

Permalink
re-add read to file implementation, updated dmg to latest version and…
Browse files Browse the repository at this point in the history
… collected installers in common package
  • Loading branch information
einaskoi committed May 26, 2026
1 parent a393e2a commit 67f3382
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
Binary file removed Millions-1.1.0-installer.exe
Binary file not shown.
Binary file removed Millions.exe
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private List<String> getPositiveHeadlines() {
goodNews.add("Turns out the product of " + company + " is good for the environment.");

goodNews.add("Beaver population increased due to the efforts of " + company);
goodNews.add("Eminem dropped new hit single, namedropping " + company);
goodNews.add("Famous artist dropped new hit single, namedropping " + company);

goodNews.add("Founder of " + company + " seen feeding the homeless.");
goodNews.add(company + " got frontpage in new forbes magazine, "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package edu.ntnu.idi.idatt2003.gruppe42.model;

import edu.ntnu.idi.idatt2003.gruppe42.model.exceptions.StockFileParseException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -134,6 +134,33 @@ public static List<Stock> readFromFile(final InputStream inputStream)
return stocks;
}

/**
* Method for writing stock information to file.
*
* @param path the relative path of the file being parsed (from source root)
* @param stocks list of stock objects to be transcribed to data file
* @throws IOException if file not found
*/
public static void writeToFile(Path path, List<Stock> stocks) throws IOException {

try (BufferedWriter writer = Files.newBufferedWriter(path)) {
writer.write("# S&P 500 Companies by Market Cap");
writer.newLine();
writer.write("# Ticker,Name,Price");
writer.newLine();

for (Stock stock : stocks) {
String line = String.format("%s,%s,%s",
stock.getSymbol(),
stock.getCompany(),
stock.getSalesPrice());

writer.write(line);
writer.newLine();
}
}
}

private static BigDecimal getBigDecimal(String rawPrice, int lineNumber, String trimmed)
throws StockFileParseException {
BigDecimal price;
Expand Down

0 comments on commit 67f3382

Please sign in to comment.