Question: import java.io.File; import java.util.ArrayList; import java.util.Scanner; public class ShippingMain { /** * Self Explanation * * * */ public static Product createProduct(Scanner fileScanner) { String

import java.io.File; import java.util.ArrayList; import java.util.Scanner;

public class ShippingMain { /** * Self Explanation * * * */ public static Product createProduct(Scanner fileScanner) { String name = ""; int sku = -1; double price = -1; double weight = -1; int destination = -1; int quantity = -1;

//TODO Student

return new Product(); }

public static ShippingManifest createManifest(ArrayList fileList) { FileHelper fileHelper = new FileHelper(); ShippingManifest shipManifest = new ShippingManifest();

for(File file: fileList) { Scanner fileScanner = fileHelper.getFileScanner(file);

Product newProd = createProduct(fileScanner); shipManifest.addProduct(newProd);

fileScanner.close(); }

return shipManifest; }

public static void printSplash() { System.out.println("Please type:"); System.out.println("\"X\" to exit program."); System.out.println("\"D\" to distribute products to addresses."); System.out.println("\"F-ZIPCODE\" to forwards products to destinations."); System.out.println("\"P\" to print current manifest."); } /** * Self Explanation * * * */ public static void go(Scanner scnr, ShippingManifest shipManifest) { printSplash();

String input = scnr.nextLine();

//TODO Student

}

public static void main(String[] args) { String directoryPath = "ShipmentFolder"; FileHelper fileHelper = new FileHelper(); ArrayList fileList = fileHelper.getFileDirectory(directoryPath);

ShippingManifest shipManifest = createManifest(fileList); System.out.println("Manifest created from " + directoryPath + "!");

shipManifest.printManifest();

Scanner scnr = new Scanner(System.in); go(scnr, shipManifest); } }

import java.io.File; import java.util.ArrayList; import java.util.Scanner; public class ShippingMain { /** *Self Explanation * * * */ public static Product createProduct(Scanner fileScanner) {String name = ""; int sku = -1; double price = -1;

public static Product createProduct(Scanners filescanner) NAME, SKU, PRICE, WEIGHT, DESTINATION, and QUANTTTY. Each file will contain each of these fields, but lines will be provided in different orders, as they may be when provided by different suppliers. Such as: NAME: Berk's Salt Lamps SKU: 90435765 PRICE: 12,99 WEIGHT: 22.5 DESTINATION: 83128 QUANTITY: 22 For setting each variable you will need to use String,substring O. Integer.parseInt(int) and Double.parseDouble(double) will also come in handy for parsing and setting each variable. If the fields is not NAME, SKU, PRICE, WEIGHT, DESTINATION, or QUANTTTY print an error, but still create the object. For your loop and reading a line from the Scanner object, the Scanner.hasNextLineO and Scanner.nextLine() methods will help! After reading through the entire file and setting the appropriate variables, create and return the new Product object. Parameters: fi leScanner - seanner set to a File object and ready to be read from. Returns: Product that is created from file contents. public static ShippingManifest createManifest(ArrayList B

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!