logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Implement an Invoice class that holds the invoice data, namely, customer id, invoice id, and amount. Objects of this class represent the data or information component of the linked list nodes.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

The purpose of this assignment is to, practice creating and using linked lists, particularly, doubly linked lists with head and tail pointers.

1.   Produce Customer Invoice Lists

A spare parts wholesale company provides its customer businesses with spare parts. Every monthly accounting period closure, the company processes all the customer invoices, then it processes return and exchange transactions to finally print out lists of invoices grouped by customer id and dispatch them to the respective customers for settlement.

The system that prepares the invoice lists first uses a text file that contains all the invoices of the month as the first input text file. The first line of the file – InvoiceData.txt – contains the number of customers with invoices to process.The second line contains the customer ids assigned to each of those customers. The rest of the file consists of invoice entries that are made up of the CustomerId, InvoiceId, and, InvoiceAmount. Here is a sample of the InvoiceData file:

Line1:       3      Number of customers

Line2:        DST6000 , QDD7000 , SMF8000

Customer Ids

Line3 and on:          SMF8000   ,   1903-0001 , 7825.10

QDD7000  ,   1903-0002 , 2449.62

QDD7000 , 1903-0003 , 19825.38

SMF8000   , 1903-0004 , 521.92

DST6000    ,   1903-0005 , 4833.77

SMF8000   ,   1903-0006 , 3624.65

SMF8000   ,   1903-0007 , 80031.70

DST6000    ,   1903-0008 , 11500.00

QDD7000 , 1903-0009 , 738.55

         

Customer          Invoice         Invoice Id                      Id Amount

The system reads each invoice data line and creates an Invoice object that becomes the data item that a node of a doubly-linked list stores. New invoice nodes are to be added to the end of the linked list.

The following is a sample printout of the unsorted linked list with the invoice data nodes:

Once all invoice data is read from the input file and added as nodes to the linked list, it is passed to a sort method to sort the nodes based on the customer id and amount. I.e. the list is to be sorted in ascending order using the customer id first, then the invoice’s amount.

The sorted linked list should look something like the sample below:

The next step is to update the list by processing the entries provided in the returns and exchanges text file – ReturnsData.txt. The data in this file consists of entries of return transactions that start with the EntryCode “750”, and exchange transactions which start with the EntryCode “850”. The rest of the data in each line of the returns and exchange transactions is the same as the data in the invoice entries in the invoice data file.

Your task in this assignment is to do the following:

  • Implement an Invoice class that holds the invoice data, namely, customer id, invoice id, and Objects of this class represent the data or information component of the linked list nodes. Make the invoice class implement the Comparable interface and override the compareTo method to make it compare two invoices based on customer id first, if it is the same customer, then it proceeds to compare the two amounts. Remember that when you are comparing the amounts, you need to use the very small TOLERANCE value to make sure that the result of the floating point comparison is correct. Here is how you should compare the amounts:

double TOLERANCE = 1E-14;

if ((Math.abs(this.getAmount() - other.getAmount()) < TOLERANCE)) return 0;

else if ((this.getAmount() - other.getAmount()) < TOLERANCE) return -1;

else

return 1;

 

 

  • Create a doubly linked list class, InvoiceLinkedList, that has head and tail pointers, and an integer variable to keep track of the number nodes in the Here is a list of the methods your doubly linked list class should implement:

    • size() : Returns the current total number of nodes in the

 

  • add (Invoice invoice) : Creates a new node by passing the invoice object to its constructor and adds the node to the end of the

  • insert (Invoice invoice) : Creates a new node by passing the invoice object to its constructor and insert it at the proper location in the sorted

  • get (int index) : Returns the invoice object that is stored in the node at the specified

  • remove (Invoice invoice) : Removes the node that contains the passed invoice It returns true if the removal was successful, else it returns false.

  • swapValues (int Index1, int Index2) : Swaps the invoice objects between the two nodes at the indicated indexes. This method is to be called by the sort methods to swap the

  • print () : Prints the invoice information on the linked list from head to tail using the next

 

  • printBackwards () : Prints the invoice information on the linked list from tail backwards to head using the previous

  • getCustomerSublist (String customerId) : Returns a doubly linked sub-list of the bigger doubly linked list. The returned sub-list should contain all the nodes with the specified customer

Note: Those are the main methods you need to implement in the doubly linked list class. However, you may implement any extra helper methods you need to help deliver the required functionalities.

  • Implement an inner (private) Node class that represents the nodes of the double linked list. The Node class should have a variable of type Invoice to hold invoice objects plus the next, and previous

  • Implement a Sorter class that has a sort method to sort the invoice objects in the doubly linked list. The sort method should receive the InvoiceLinkedList as a parameter, compare the invoice objects in the list nodes, and use the swapValues method – of the InvoiceLinkedList – to make the actual swapping of the invoice objects between the list

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

532 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

773 Answers

Hire Me
expert
Husnain SaeedComputer science

519 Answers

Hire Me
expert
Atharva PatilComputer science

992 Answers

Hire Me

Get Free Quote!

271 Experts Online