0% found this document useful (0 votes)
3 views3 pages

Lab 6 Tasks

The document outlines tasks for Lab 6 focused on Warehouse Inventory Management, requiring the implementation of a Container class with various constructors, methods for calculating storage capacity, and access control for private data. Students must create a Word document with their results, including code and screenshots, and submit it on time to avoid penalties. The tasks include creating constructors, implementing a copy constructor, and demonstrating resource cleanup with destructors.

Uploaded by

sm-malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Lab 6 Tasks

The document outlines tasks for Lab 6 focused on Warehouse Inventory Management, requiring the implementation of a Container class with various constructors, methods for calculating storage capacity, and access control for private data. Students must create a Word document with their results, including code and screenshots, and submit it on time to avoid penalties. The tasks include creating constructors, implementing a copy constructor, and demonstrating resource cleanup with destructors.

Uploaded by

sm-malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab 6 Tasks

After going through Lab tasks, submit a separate Word document which should include all the results

of the tasks Code should be in word and output should be screenshot.

First page should contain your Full name, Registration #, Course name and Date

The File Should be saved with your name only.

No copied or AI Should be in Code or Explanation.

Submit on Time Marks will be deducted on late submission.

Warehouse Inventory Management


In a warehouse, containers are organized into cuboids of different dimensions, and each
has a unique identifier, volume, and storage details. This scenario will help students
understand constructors, object-oriented principles, and private data handling by
simulating inventory control for efficient space utilization.
Task 1: Constructor and Storage Capacity Calculation
• Objective: Implement a Container class with a parameterized constructor.
• Instructions:
o Define a Container class with private data members: id (string), length,
width, and height.
o Add a parameterized constructor to initialize these values.
o Include a StorageCapacity() method that calculates the container’s volume
using the formula: Storage Capacity=length×width×height\text{Storage
Capacity} = \text{length} \times \text{width} \times
\text{height}Storage Capacity=length×width×height
o In main(), create two Container objects with different dimensions and IDs,
and display their storage capacities.
Task 2: Implementing and Testing a Default Constructor
• Objective: Add a default constructor to the Container class for use when
dimensions are unknown.
• Instructions:
o Extend the Container class by adding a default constructor that prints
"Default container created."
o This default container should initialize length, width, and height to 1.0 and
set id to "Default-000".
o In main(), create a Container object using the default constructor and display
its storage capacity and ID.
Task 3: Secure Private Data and Provide Accessors
• Objective: Secure data by making members private, and provide accessors to
control access.
• Instructions:
o Make the Container class data members (id, length, width, height) private.
o Provide public getter functions for each member and a setter function for id
only (assuming IDs are assigned once and should not change).
o Demonstrate the secure access in main() by trying to access data members
directly (which should cause an error) and then using the getter functions.
Task 4: Copy Constructor and Container Replication
• Objective: Use a copy constructor to replicate a container.
• Instructions:
o Add a copy constructor to the Container class that replicates all properties
from another container.
o In main(), create a Container object (Container1) with specific dimensions
and ID.
o Use the copy constructor to create a new container (Container2) based on
Container1, simulating replication of containers.
o Display the details and storage capacities of both Container1 and
Container2 to verify they are identical.
Task 5: Destructor and Resource Cleanup Simulation
• Objective: Implement a destructor to indicate when a container is removed from
inventory.
• Instructions:
o Define a destructor in the Container class that outputs "Container [ID]
removed from inventory."
o In main(), create two Container objects within a local scope (inside a code
block).
o Observe the output to confirm the destructor is called when the objects go
out of scope, simulating cleanup when containers are removed from
inventory.

You might also like