HW-06
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
@@ -15,6 +18,20 @@ public class Main {
|
||||
}
|
||||
Scanner scanner = new Scanner(input);
|
||||
|
||||
int productId=0;
|
||||
String name=" ";
|
||||
double price=0;
|
||||
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
String[] parts = line.split(",");
|
||||
productId = Integer.parseInt(parts[0]);
|
||||
price= Double.parseDouble(parts[2]);
|
||||
Product p= new Product(productId, parts[1],price);
|
||||
productCatalog.add(p);
|
||||
}
|
||||
|
||||
|
||||
// TODO:
|
||||
// - Read each line from products.csv
|
||||
// - For each line, parse productId, name, and price
|
||||
|
||||
Reference in New Issue
Block a user