Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Packet objects have unique ID number, state abbreviation for their destination, and weight in pounds with 2 decimals. Class Packet describes packets and has variables
Packet objects have unique ID number, state abbreviation for their destination, and weight in pounds with 2 decimals. Class Packet describes packets and has variables idNumber, state, and weight of type int, String and double, respectively. In addition, it has the following methods boolean isHeavy( that returns true when packet is above 10 pounds, and false otherwise boolean isLight ( that returns true when packet is below 5 pounds, and false otherwise String tostring) returns String which is one line String representation of Packet objects double getWeight () returns packetss weight Create an input file called packetData.txt with the following 7 lines 1001 CA 17.37 1002 CT 5.17 1003 NY 11.35 1004 MA 3.17 1005 FL 9.99 1006 CT 14.91 1007 TX 24.97 Obviously, your code must work properly for any other input file with any number of lines. Class Packages has shipment variable which contains the collection of all packets. Variable shipment is of Arzavlist type. All objects in the ArzavList are of Packet type. The constructor assigns variable shipment by reading the data from the input file specified above. Each line in the file has data about one packet object and data from it should be assigned to a Packet object first and that object is added to the collection. Use input file called packetData.txt to read data from the file. Class Packages has methods ll returns String representation about entire collection of packets with one / packet object specified per line. String tostring () void displavlightPackets displays all packets that are light. void displayRegularPacket double totalNeight ( Packet heavyestPackets() I/ displays all packets that are neither light nor heavy. ll returns total weight of all packets. W returns the packet with largest weight Methods toString.) totalWeight) and beavyBackets) do not print anything, they only return specified data. Your application should also have class TestPackages with only main method in it. That class will be used to test all methods from class Packages
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