Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Quiz-1 1

National University of Computer and Emerging Sciences

Quiz-1
for
Object Oriented Programming (OOP)

Course Instructor Ms. Anosha Khan


Lab Instructor(s) Sullahuddin, Amina Qaiser
Section BSE-2A
Semester Spring 2024

Department of Computer Science


FAST-NU, Lahore, Pakistan

Quiz-1
Quiz-1 2

Instructions:
● If someone is caught using the internet in this Quiz ,their marks will be reduced to zero.
● In case of Plagiarism, Straight Zero and report this case to DC.
● Late Submission is not allowed. If someone evaluated his/her code then he/she will submit
the code in google classroom and then leave the class.

Question: Inventory Management System

In this scenario, you are tasked with developing an inventory management system for a warehouse.
Each item in the inventory has attributes such as a unique ID, name, quantity, and price. To
represent each item, you decide to create a class called Item. The inventory data will be stored in a
2D dynamic array of Item objects. You need to implement functions to add, remove, and update
item records, as well as generate reports on inventory status.

Item Class:

The Item class will have the following private attributes:

● id: Unique identifier for each item.


● name: Name or description of the item.
● quantity: Quantity of the item available in the inventory.
● price: Price of the item.

Additionally, you will implement getter, setter, constructors and destructors methods for each
attribute to ensure encapsulation and access control.

Inventory Management Functions:

1. Add Item: Implement a function to add a new item to the inventory. The function should
take the ID, name, quantity, and price of the item as parameters and add it to the 2D
dynamic array.
2. Remove Item: Implement a function to remove an item from the inventory based on its ID.
The function should search for the item with the given ID and remove it from the array if
found.
3. Update Item: Implement a function to update the details of an existing item in the
inventory. The function should take the ID of the item to be updated and new values for its
attributes (name, quantity, and price). It should search for the item with the given ID and
update its details accordingly.
4. Generate Inventory Report: Implement a function to generate a report on the current
status of the inventory. This report should include details such as the ID, name, quantity,
and price of each item in the inventory.

Examples:

Let's consider a few examples to demonstrate how the inventory management system works:
Quiz-1 3

1. Adding an Item:

Input:
Item ID: 001
Item Name: Laptop
Quantity: 10
Price: $800

Output:
Item added successfully!

2. Removing an Item:

Input:
Enter ID of the item to remove: 002

Output:
Item with ID 002 removed successfully!

3. Updating an Item:

Input:
Enter ID of the item to update: 001
New Name: Desktop
New Quantity: 5
New Price: $1000

Output:
Item with ID 001 updated successfully!

4. Generating Inventory Report:

Inventory Report:

ID Name Quantity Price


--------------------------------------
001 Desktop 5 $1000
003 Monitor 15 $200
004 Printer 8 $300

You might also like