Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to write a program using object oriented programming idea for boxes. That is, each box has to be considered an object. To achieve

You need to write a program using object oriented programming idea for boxes. That is, each box has to be considered an object. To achieve this, you must write a class named Box. Therefore, make sure to create a Java file for the Box class. You can only read the file exactly once, and you are not allowed to use an array to store box objects. Some other required properties of the Box class are as follows.

1. 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.

2. Write no more than two constructors.

3. The Box class must have a public method named getVolume() that will return the volume of the box.

4. The Box class must have a public method named isCube() that will return true if the box is cubic, false otherwise.

5. 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.

1. Read the input text file provided by the client and create a linked list of Box objects. The sequence of the lines should be used in the sequence of objects in the linked list.

2. 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.

4. How many cubic boxes are there in the linked list?

5. 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.

6. 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.

7. Report average volume of all boxes.

8. 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 three is inevitable. If you want, you can easily avoid the split method and this array of size three by using java.util.StringTokenizer. However, there is no extra credit for the use of StringTokenizer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions