I fixed the main part and part of the report.

This commit is contained in:
Matin
2026-05-21 02:26:19 +04:30
parent 8e6d1d1760
commit b3918fd47f
2 changed files with 152 additions and 9 deletions
+48 -2
View File
@@ -14,6 +14,53 @@ public class Main {
throw new IOException("products.csv not found");
}
Scanner scanner = new Scanner(input);
while (scanner.hasNextLine())
{
String ln = scanner.nextLine() ;
int part_number = 0 ;
String part = "";
String product_id = "" ;
String product_name = "" ;
String product_price = "" ;
for (char x : ln.toCharArray() )
{
if (x != ',')
{
part = part + x ;
}
else if (x == ',')
{
switch (part_number)
{
case 0 :
product_id = part ;
part = "" ;
part_number ++ ;
break;
case 1 :
product_name = part ;
part = "" ;
part_number ++ ;
break;
case 2 :
product_price = part ;
part = "" ;
part_number ++ ;
break;
}
}
productCatalog.add(new Product(Integer.parseInt(product_id), product_name , Float.parseFloat(product_price))) ;
}
}
// TODO:
// - Read each line from products.csv
@@ -26,8 +73,7 @@ public class Main {
// - The data in products.csv is guaranteed to be valid.
}
public static void main(String[] args)
{
public static void main(String[] args) throws IOException {
try {
loadProducts();
} catch (IOException e) {