Objective The goal of this assignment is to practice linked
Objective: The goal of this assignment is to practice linked list of objects. Background: The local packaging company comes back to you (again). They are very happy with your linked list based program. They would like to add more linked list functionality in the program. As you know from Lab Assignment 3, an input file may look like the following one.
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
Each line contains the width, height and length of a box. The dimensions are separated by spaces. In Lab Assignment 3, you created your won linked list; you were not allowed to use any java.util lists for this revised software. The same conditions apply for this new assignment. Assignment: All the following conditions from the previous assignment apply for the new one. You will not make any change to the Box class.
1. You are allowed to keep only the next variable 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.
public class Box { //These are the integer data fields for length, width and height.
private int length;
private int width;
private int height; /**The constructor that takes one argument should assign the value to length and assign zeros to height and width.*/
public Box(int l) {
length= 2;
width= 0;
height= 0;
}
public Box(int l, int w) { //Write the code to set the private fields
length= 1;
width= 3;
height= 0;
}
public Box(int l, int w, int h) { // write code to set the private fields
length= 3;
width= 6;
height= 9; } // Write and set methods for length
public int getLength() {
return length; }
public void setLength(int l) {
length=l; } // Write get and set methods for width
public int getWidth() {
return width; }
public void setWidth(int w) {
width=w; } // Write get and set methods for height
public int getHeight() {
return height; }
public void setHeight(int h) {
height=h; } }
and this is the BoxTest code
Solution
import java.lang.*;
import java.io.*;
package boxcount{
public class Box
{
private int length;
private int width;
private int height;
Box(int side)
{
length=side;
width= side;
height=side;
}
public void getvolume( )
{
int volume= length*width-heigth;
system.out.printn(\"volume of cube box is\"+ volume);
}
public void cube( )
{
if (side=side=side)
system.out.println(\"box is cube\");
else
system.out.println(\"box is not cube\");
}
import boxcount.*;
{class test
public static void main ( String args[])
{
box bc=new box (10);
bc.getvolume();
bc.cube();
}


