Respuesta :
Answer:
C++
Explanation:
class MyBoxes {
private:
// Pointer to Box object and array size. Required for dynamically creating an array.
Box* boxes;
int array_size;
// Constructor
MyBoxes(int array_size) {
self.array_size = array_size;
boxes = new Box[array_size] ;
}
public:
// Methods
int emptyspace() {
int count = 0;
for (int i=0; i < self.array_size; i++) {
// Check for null
if (!boxes[i])
count++;
}
return count;
}
void add(int length, int width, int height) {
Box box1(length, width, height);
if (self.emptyspace() == 0) {
self.addToArray(box1);
}
}
void print() {
Box *temporaryBox;
for (int i=0; i < self.array_size; i++) {
temporaryBox = boxes[i];
if (temporaryBox) {
cout<<temporaryBox->length<<endl;
cout<<temporaryBox->width<<endl;
cout<<temporaryBox->height<<endl;
}
}
// Free memory
delete temporaryBox;
}