implement loadProducts method

This commit is contained in:
2026-05-16 15:43:25 +03:30
parent 8e6d1d1760
commit b692d0cbc3
+8 -9
View File
@@ -15,15 +15,14 @@ public class Main {
}
Scanner scanner = new Scanner(input);
// TODO:
// - 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
// - The data in products.csv is guaranteed to be valid.
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
String[] cells = line.split(",");
int productID = Integer.parseInt(cells[0]);
String productName = cells[1];
double price = Double.parseDouble(cells[2]);
productCatalog.add(new Product(productID, productName, price));
}
}
public static void main(String[] args)