Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use python code In this lab, you will implement a class called Truck containing a collection of Box objects. Any Box object has attributes
Please use python code
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 eq (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 implementinit_ method. Note that Truck does not extend Box class and it only contains a list of boxesStep 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