Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Explain this code in details in paragraph style. /* * To change this license header, choose License Headers in Project Properties. * To change this

Explain this code in details in paragraph style.

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package orderhandler;

/**

*

* @author Muhammad.Adnan

*/

import java.io.IOException;

import java.nio.file.*;

import java.util.*;

import java.util.regex.Pattern;

public class OrderHandler {

private static final String FILENAME = "deliveryitem.txt";

List data;

public OrderHandler() {

try {

data = Files.readAllLines( Paths.get( FILENAME ) );

} catch (IOException e) {

e.printStackTrace();

}

}

//display all order information except the heading text

void print( List> orderLst ) {

orderLst.forEach((n) -> { System.out.println(n); });

}

//collect all orders and split them with '\'

List> collect(){

List> orderLst = new ArrayList();

data.forEach((i)->orderLst.add(Arrays.asList(i.split( Pattern.quote("\\") ))));

orderLst.removeIf(i->i.contains("PARCELITEM"));

return orderLst;

}

//compute the total payment of order placed

double computePaymnt( List> orderLst ) {

final double[] sum = {0};

orderLst.forEach((i)-> sum[0] +=Double.parseDouble(i.get(i.size()-1)));

return sum[0];

}

//export to order object comprises name and charges only

List populate( List> orderLst ){

List items = new ArrayList();

orderLst.forEach((i)->items.add(new Item(i.get(0),i.get(i.size()-1))));

return items;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions