develop #1

Open
Parmis_jamami wants to merge 2 commits from develop into main
Showing only changes of commit 70ad289338 - Show all commits
+13 -11
View File
@@ -13,21 +13,23 @@ public class Main {
if (input == null) { if (input == null) {
throw new IOException("products.csv not found"); throw new IOException("products.csv not found");
} }
Scanner scanner = new Scanner(input);
// TODO: try (Scanner scanner = new Scanner(input)) {
// - Read each line from products.csv while (scanner.hasNextLine()) {
// - For each line, parse productId, name, and price String line = scanner.nextLine();
// - The format of the file is like this: if (line.isBlank()) continue;
// [productId],[name],[price]
// - Store Product objects in the productCatalog ArrayList
// NOTE String[] parts = line.split(",");
// - The data in products.csv is guaranteed to be valid. int id = Integer.parseInt(parts[0].trim());
String name = parts[1].trim();
double price = Double.parseDouble(parts[2].trim());
productCatalog.add(new Product(id, name, price));
}
}
} }
public static void main(String[] args) public static void main(String[] args) throws IOException {
{
try { try {
loadProducts(); loadProducts();
} catch (IOException e) { } catch (IOException e) {