Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a complete Class for an object called a Box. The Box should have three integer instance variables, one for the length, one for the

Write a complete Class for an object called a Box. The Box should have three integer instance variables, one for the length, one for the width and one for the height of the Box. Provide two constructors: one with no parameters that creates a box with a length, width and height of one, and a three-argument constructor that creates a Box with the given length, width and height. Error checking should be done to ensure none of the parameters is less than one. Include get and set methods for each of the instance variables, again with appropriate error detection. Provide a public, no- parameter method called volume that will return the volume of the Box (i.e., length times width times height). Override the methods equals and toString that are inherited from class Object. A call to the toString method should result in a String as follows (given the input line cited below):

L:12 W:4 H:15

Write a main program that will read Box information from a file and store the Boxes in an array. The format of the input file will be three integers per line separated by commas, representing the length, width and height of the Box:

12,4,15

Write a class called BoxGUI that extends JFrame. The BoxGUI should contain a grid layout with one row and two columns. Display the original array in the left column, and then sort the array (by volume) and display it in the right column. Use Selection Sort as shown in class to sort the array. The display of the Boxes should be done using the toString method of class Box.

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago