Skip to content
Snippets Groups Projects
Commit 189835ff authored by Neha Bagga's avatar Neha Bagga
Browse files

Developed Basic Inventory System

parent b75125e3
No related branches found
No related tags found
No related merge requests found
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Toy {
private:
string name;
string material;
string description;
double manufacturingPrice;
int quantityInStock;
public:
Toy(string n, string m, string desc, double price, int quantity)
: name(n), material(m), description(desc), manufacturingPrice(price), quantityInStock(quantity) {}
// Getter methods
string getName() const { return name; }
string getMaterial() const { return material; }
string getDescription() const { return description; }
double getManufacturingPrice() const { return manufacturingPrice; }
int getQuantityInStock() const { return quantityInStock; }
// Setter methods
void setName(string n) { name = n; }
void setMaterial(string m) { material = m; }
void setDescription(string desc) { description = desc; }
void setManufacturingPrice(double price) { manufacturingPrice = price; }
void setQuantityInStock(int quantity) { quantityInStock = quantity; }
// Display toy details
void display() const {
cout << "Toy Name: " << name << endl;
cout << "Material: " << material << endl;
cout << "Description: " << description << endl;
cout << "Manufacturing Price: $" << manufacturingPrice << endl;
cout << "Quantity in Stock: " << quantityInStock << endl;
}
};
class Inventory {
private:
vector<Toy> toys;
public:
// Add a new toy to the inventory
void addToy(const Toy& toy) {
toys.push_back(toy);
}
// Display all toys in the inventory
void displayInventory() const {
cout << "=== Inventory ===" << endl;
for (const Toy& toy : toys) {
toy.display();
cout << "----------------" << endl;
}
}
};
int main() {
Inventory inventory;
// Adding sample toys to the inventory
Toy toy1("Toy1", "Plastic", "A fun toy", 5.99, 50);
Toy toy2("Toy2", "Wood", "Educational toy", 9.99, 30);
inventory.addToy(toy1);
inventory.addToy(toy2);
// Display the inventory
inventory.displayInventory();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment