Part 1 completed.

This commit is contained in:
2026-05-20 01:54:10 +03:30
parent 8e6d1d1760
commit 4746189bf2
+12 -8
View File
@@ -2,6 +2,7 @@ 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.Collections;
import java.util.List;
import java.util.Scanner; import java.util.Scanner;
public class Main { public class Main {
@@ -15,15 +16,18 @@ public class Main {
} }
Scanner scanner = new Scanner(input); Scanner scanner = new Scanner(input);
// TODO: List<Product> productCatalog = new ArrayList<>();
// - Read each line from products.csv
// - For each line, parse productId, name, and price
// - The format of the file is like this:
// [productId],[name],[price]
// - Store Product objects in the productCatalog ArrayList
// NOTE while (scanner.hasNextLine()) {
// - The data in products.csv is guaranteed to be valid. String line = scanner.nextLine();
String[] columns = line.split(",");
int productId = Integer.parseInt(columns[0]);
String name = columns[1];
double price = Double.parseDouble(columns[2]);
productCatalog.add(new Product(productId, name, price));
}
} }
public static void main(String[] args) public static void main(String[] args)