Question: COMPLETE THE FOLLOWING PROGRAM IN PYTHON: Arrangement of boxes In this lab, you will implement a class called Truck containing a collection of Box objects.
COMPLETE THE FOLLOWING PROGRAM IN PYTHON:


Arrangement of boxes In this lab, you will implement a class called Truck containing a collection of Box objects. Any Box object has attributes length, width, and height. The class Truck should be able to sort contained boxes based on given criteria and rotate the sequence either to the right or to the left. Box class We build a Box class with the following ADT -init-(self, length, width, height ) -initialize a Box object with length, width, and height attributes. volume(self) return the volume of the Box it(self, other) return True if the volume of self is less than the volume of other (self, other) return True if and only if self and other have the same volume. .-le-(self, other) -return True if the volume of self is not greater than the volume of other Start by writing a class called Box and store it in a file called boxarrangement.py Then, implement its methods using the above ADT. Truck Class. It stores a collection of boxes in a sequence. We create a Truck class with the following ADT .init__(self, boxes) - initialize a new truck with the list boxes .sort(self, key-None) -Sort the containing boxes in-place based on a given key function. sortbyvolume (self) Sort the boxes in-place based on their volume. .sortbylength(self) - Sort the boxes in-place based on their length. sortbyheight (self) -Sort the boxes in-place based on their height rotate(self, k)-Rotate the sequence of boxes k steps. Add a class called Truck to your boxarrangement.py file and implement_init_ method. Note that Truck does not extend Box class and it only contains a list of boxes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
