feat: update Main.java todos

This commit is contained in:
2026-05-14 16:20:00 +03:30
parent 5e0bae3c43
commit 41f488a81a
+11 -3
View File
@@ -1,14 +1,18 @@
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner; import java.util.Scanner;
public class Main { public class Main {
static ArrayList<Product> productCatalog = new ArrayList<>(); static ArrayList<Product> productCatalog = new ArrayList<>();
public static void loadProducts() throws IOException { public static void loadProducts() throws IOException{
InputStream input = Main.class InputStream input = Main.class
.getClassLoader() .getClassLoader()
.getResourceAsStream("products.csv"); .getResourceAsStream("products.csv");
if (input == null) {
throw new IOException("products.csv not found");
}
Scanner scanner = new Scanner(input); Scanner scanner = new Scanner(input);
// TODO: // TODO:
@@ -27,12 +31,16 @@ public class Main {
try { try {
loadProducts(); loadProducts();
} catch (IOException e) { } catch (IOException e) {
System.err.println("Something went wrong with loading products!\nterminating the program..."); System.err.println("Error reading products");
System.out.println("Terminating the program...");
return; return;
} }
System.out.println("=== Products loaded");
ReportGenerator reportGenerator = new ReportGenerator("2025_order_details.csv", productCatalog); ReportGenerator reportGenerator = new ReportGenerator("2025_order_details.csv", Collections.unmodifiableList(productCatalog));
reportGenerator.processFile(); reportGenerator.processFile();
System.out.println("=== Order file processed");
reportGenerator.saveReport(); reportGenerator.saveReport();
System.out.println("=== Report saved as report.txt");
} }
} }