CS301P Assignment No. 1 (Recovered) With Solution
CS301P Assignment No. 1 (Recovered) With Solution
01
Total Marks: 20
SEMESTER Fall 2024
Due Date: 09-Nov, 2024
CS301P- Data Structures (Practical)
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
o The assignment is submitted after the due date.
o The submitted code does NOT compile.
o The submitted assignment is other than .CPP file.
o The submitted assignment does NOT open or file is corrupted.
o The assignment is copied (from other student or ditto copy from handouts or internet).
Uploading instructions
For clarity and simplicity, you are required to Upload/Submit only ONE .cpp template file after completing its
code.
Note:
1. Use ONLY Dev-C++ IDE.
2. Only add the code were commented (// Write your code here) in given .cpp template file. Don’t change
any other code otherwise you will lose your marks.
3. Only implement these functions addPart(), deletePart(), updateQuantity(), findPart().
Objective
The objective of this assignment is
GOOD LUCK
Marks: 20
You are tasked with developing the "Computer Parts Management System," designed to manage the inventory of
a computer parts store using Linked List data structure. The system should store details about each computer part,
including its ID, name, and quantity in stock. It must support adding new parts, removing parts, updating the
quantity of parts, and finding parts in the inventory.
Tasks:
1. Understand the provided code:
Read and understand the given .cpp file which is uploaded on VULMS with your assignment file. This
file outlining the class structure for managing the computer parts inventory.
2. Implement the addPart() function:
Complete the method to add a new part to the inventory linked list.
3. Implement the deletePart() function:
Complete the method to remove a part from the inventory based on the part ID.
4. Implement the updateQuantity() function:
Complete the method to update the stock quantity for an existing part.
5. Implement the findPart() function:
Complete the method to find and display a part by its part ID.
6. Mention your own student id instead of BCxxxxxxxxx as given in the output screenshot.
Note:
1. Especially handle head, current and previous pointers properly in all four functions using liked list.
2. After completing your code your output will be like the given output screenshot.
Lectures Covered: This assignment covers Lab # 1. (First three lectures of CS301).
Deadline: Your assignment must be uploaded/submitted on or before, Nov 09, 2024.
Solution
#include <iostream>
#include <string>
using namespace std;
public:
Inventory() : head(nullptr) {}
if (current == nullptr) {
cout << "Part ID " << partId << " not found." << endl;
return;
}
delete current;
cout << "Part ID " << partId << " deleted." << endl;
}
cout << "Part ID " << partId << " not found." << endl;
}
cout << "Part ID " << partId << " not found." << endl;
}
int main() {
Inventory inventory;
// Finding a part by ID
cout << "\nFinding Part ID 101:" << endl;
inventory.findPart(101);
// Deleting a part and updating quantity
cout << "\nAfter deleting SSD and updating RAM Quantity..." << endl;
inventory.deletePart(101);
inventory.updateQuantity(102, 50);
return 0;
}