diff --git a/src/.idea/.gitignore b/src/.idea/.gitignore
new file mode 100644
index 0000000..ab1f416
--- /dev/null
+++ b/src/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/src/.idea/misc.xml b/src/.idea/misc.xml
new file mode 100644
index 0000000..a20905f
--- /dev/null
+++ b/src/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.idea/modules.xml b/src/.idea/modules.xml
new file mode 100644
index 0000000..3d0bbe7
--- /dev/null
+++ b/src/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.idea/vcs.xml b/src/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/src/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
index 148a46e..8117402 100644
--- a/src/main/java/Main.java
+++ b/src/main/java/Main.java
@@ -13,17 +13,20 @@ public class Main {
if (input == null) {
throw new IOException("products.csv not found");
}
+
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
+ while (scanner.hasNextLine())
+ {
+ String line = scanner.nextLine();
+ String[] parts = line.split(",");
+ int id = Integer.parseInt(parts[0].trim());
+ String name = parts[1].trim();
+ Double price = Double.parseDouble(parts[2].trim());
- // NOTE
- // - The data in products.csv is guaranteed to be valid.
+ productCatalog.add(new Product(id, name, price));
+ }
+ scanner.close();
}
public static void main(String[] args)