Question
Use the inventoryNew.txt as input file to build a Max-Heap (java PriorityQueue). The order of the priority queue is the reverse order of part number.
Use the inventoryNew.txt as input file to build a Max-Heap (java PriorityQueue). The order of the priority queue is the reverse order of part number. At the end, print the Max-Heap in iterator order and then print the same Max-Heap in priority queue order. Download Inventory.java and inventoryNew.txt
inventory.java
//******************************************************************** // Inventory.java // //********************************************************************
public class Inventory { protected String PartNo; protected String Model; protected String Description; protected Double ListPrice;
//----------------------------------------------------------------- // Constructor: Sets up this inventory using the specified // information. //----------------------------------------------------------------- public Inventory() { } public String GetPartNo() { return PartNo; } public void SetInventory (String ePartNo, String eModel, String eDescription, Double eListPrice) { PartNo = ePartNo; Model = eModel; Description = eDescription; ListPrice = eListPrice; }
//----------------------------------------------------------------- // Returns a string including the basic inventory information. //----------------------------------------------------------------- public String toString() { String result = null; if (PartNo != null) { result = "Part Number: " + PartNo + " "; result += "Model: " + Model + " "; result += "List Price: "+ Double.toString(ListPrice) + " "; result += "Description: " + Description + " "; } return result; }
//----------------------------------------------------------------- // //----------------------------------------------------------------- public String getPartNo() { return PartNo; } public String getModel() { return Model; } public String getDesc() { return Description; } public double getListPrice() { return ListPrice; }
}
inventoryNew.txt
GT12C1068A,YUKON XL,07-14 GMC YUKON XL RT Front fender brace Lower Bracket Hinge,24.00 NI27E1251B,ALTIMA SDN,13-15 NISSAN ALTIMA SDN RT Front fender liner From 10-12 (CAPA),63.00 NI23H1297A,ALTIMA SDN,13-15 NISSAN ALTIMA SDN LT Front fender liner From 10-12 (CAPA),48.00 CV15F1067A,SILVERADO 1500 (NEW),07-13 CHEVY SILVERADO 1500 LT Front fender brace Lower Bracket Hinge,23.00 HY07E1288A,SONATA,15-16 HYUNDAI SONATA Front bumper cover 2.4L Std Type w/o Park Assist prime (CAPA),326.00 CV20B1225B,SILVERADO 1500 HYBRID,09-13 CHEVY SILVERADO 1500 HYBRID LT Front fender brace Lower Bracket Hinge,23.00 CV39A1251A,AVALANCHE,07-13 CHEVY AVALANCHE RT Front fender brace Lower Bracket Hinge,24.00 CV39A1250A,SUBURBAN,07-14 CHEVY SUBURBAN RT Front fender brace Lower Bracket Hinge,24.00 AC12C1250AQ,MDX,07-13 ACURA MDX LT Front fender liner (CAPA),68.00 AC12C1251AQ,MDX,07-13 ACURA MDX RT Front fender liner (CAPA),68.00
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started