Objective: The goal of this assignment is to practice linked list of objects.
Background: El Paso Packaging and Supply Co. comes back to you. They need your help to convert the array-based packaging to a linked-list based packaging. Additionally, the client would like to change the name of the class Package to Box.
From Lab Assignment 3, you know that a sample file may look like the following one.
The input file must be named input.txt. Each line contains the width, height and length of a box. The dimensions are separated by spaces. For Lab assignment 4, you must read the input file exactly once. The client is NOT allowing the use of any array to store Box objects, or java.util lists for this revised software.
Assignment: You need to write a program, where each box has to be considered an object. To achieve this, you must write a class named Box. The client likes to keep each class in a separate Java file. Therefore, make sure to create a Java file for the Box class. Some other required properties of the Box class are as follows.
You are allowed to keep only one of the status variables public. The rest of the status variables of the Box class must be private.
Write no more than two constructors.
The Box class must have a public method named getVolume() that will return the volume of the box.
The Box class must have a public method named isCube() that will return true if the box is cubic, false otherwise.
The Box class must NOT contain any main method.
Feel free to write any additional method in the Box class, as you see fit.
The program file (the Java file that contains the main method) must be written in Runner.java. Runner must have the following functionalities. Each functionality must be implemented in a separate method in Runner.
Find the smallest box in the linked list. Report the position, dimensions, and volume of the smallest object. Position of an object in a linked list is equivalent to the index of an array.
Find the largest box in the linked list. Report the position, dimensions, and volume of the largest object. You already know what a position in a linked list means.
How many cubic boxes are there in the linked list?
What are the position, dimensions, and volume of the smallest cubic box in the linked list? If multiple boxes have the same smallest cubic size, report only the one that appeared the earliest in the input file.
What are the position, dimensions, and volume of the largest cubic box in the linked list? If multiple boxes have the same largest cubic size, report only the one that appeared the earliest in the input file.
Report average volume of all boxes.
Report average volume of cubic boxes.
Note: It is ok to use a one-dimensional array of length three to keep width, length, and height of a box for string-splitting purpose. You cannot use any array of size larger than three for this assignment. If you use the split method, then this array of size of three is inevitable.
Deliverables: You are expected to submit two Java files (Box.java and Runner.java) via Blackboard. You have to demo your programs within one week after the due date. Your demo will be based on your last submission in the Blackboard. Your TA will instruct you with further details.