Question
Objective : The goal of this assignment is to practice array of objects. Background : El Paso Packaging and Supply Co. has contracted you to
Objective: The goal of this assignment is to practice array of objects.
Background: El Paso Packaging and Supply Co. has contracted you to create a software to summarize their inventory.
The client saves dimensions of packages in the inventory in a text file. While it sounds inefficient, the client is an angel from programmers point of view. J This is because it is possible to write a program that will directly read from the file and create a summary of the inventory. A sample file is shown below.
20 10 8
4.5 8.45 12.2
8.0 2.5 4.0
1.0 15.0 18.0
3.5 3.5 3.5
6.0 5.0 10.0
That is, each line contains the width, height, and length of a package. The dimensions are separated by spaces.
Assignment: You need to write a program using object oriented programming idea for packages. That is, each package must be considered an object. To achieve this, you must write a class named Package. Make sure to create a Java file for the Package class. Some other required properties of the Package class are as follows.
1. All status variables of the Package class must be private.
2. Write no more than two constructors.
3. Must have a public method named getVolume() that will return the volume of the package.
4. Must have a public method named isCube() that will return true if the package is cubic, false otherwise.
5. The Package class must NOT contain any main method.
Feel free to write any additional method in the Package class, as you see fit.
The program file (the Java file that contains the main method) must be written in a file named Runner.java. The Runner class must not have any status variable. Runner must have the following functionalities. Each functionality must be implemented in a separate method in Runner.
1. Read the input text file provided by the client and create an array of Package objects. The sequence of the lines should be used in the sequence of objects in the array.
2. Find the largest package in the array. Report the index, dimensions, and volume of the largest object.
3. How many cubic and non-cubic packages are there in the array?
4. Report the indices and dimensions of the cubic packages
5. Report average volume of cubic packages only.
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