Skip to main content
Post Closed as "Not suitable for this site" by Stephen Rauch, Sᴀᴍ Onᴇᴌᴀ, hjpotter92, Dan Oberlam, user34073
edited title
Link
Mast
  • 13.5k
  • 12
  • 54
  • 119

Simple Product Inventory Projectproduct inventory project

deleted 3 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Simple Product Inventory Project - Python

The goal: "Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an inventory class which keeps track of various products and can sum up the inventory value."

Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an inventory class which keeps track of various products and can sum up the inventory value.

I figured out how to get a list of dictionaries, and then add up the price. My output isn't pretty, but before I continue, I would simply like general critique.

 class Product:
    def __init__(self, i, p, q):
        self.identification = i
        self.price = p
        self.quantity = q
        self.item_dictionary = {'ID: ': self.identification, 'Price: ': self.price, 'Quantity: ': self.quantity}


class Inventory:
    def __init__(self):
        self.identification, self.price_list, self.quantity_list = [], [], []
        self.products = [
            product_1.item_dictionary,
            product_2.item_dictionary
        ]  # Make list of item dictionaries

    for i in self.products:
        self.identification.append(i['ID: '])
        self.price_list.append(i['Price: '])
        self.quantity_list.append(i['Quantity: '])
        # Make unique lists of ID, Price, and Quantity

    print(sum(self.price_list))


product_1 = Product(32, 23, 2)
product_2 = Product(23, 65, 3)


inventory_1 = Inventory()

Simple Product Inventory Project - Python

The goal: "Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an inventory class which keeps track of various products and can sum up the inventory value."

I figured out how to get a list of dictionaries, and then add up the price. My output isn't pretty, but before I continue, I would simply like general critique.

 class Product:
    def __init__(self, i, p, q):
        self.identification = i
        self.price = p
        self.quantity = q
        self.item_dictionary = {'ID: ': self.identification, 'Price: ': self.price, 'Quantity: ': self.quantity}


class Inventory:
    def __init__(self):
        self.identification, self.price_list, self.quantity_list = [], [], []
        self.products = [
            product_1.item_dictionary,
            product_2.item_dictionary
        ]  # Make list of item dictionaries

    for i in self.products:
        self.identification.append(i['ID: '])
        self.price_list.append(i['Price: '])
        self.quantity_list.append(i['Quantity: '])
        # Make unique lists of ID, Price, and Quantity

    print(sum(self.price_list))


product_1 = Product(32, 23, 2)
product_2 = Product(23, 65, 3)


inventory_1 = Inventory()

Simple Product Inventory Project

The goal:

Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an inventory class which keeps track of various products and can sum up the inventory value.

I figured out how to get a list of dictionaries, and then add up the price. My output isn't pretty, but before I continue, I would simply like general critique.

class Product:
    def __init__(self, i, p, q):
        self.identification = i
        self.price = p
        self.quantity = q
        self.item_dictionary = {'ID: ': self.identification, 'Price: ': self.price, 'Quantity: ': self.quantity}


class Inventory:
    def __init__(self):
        self.identification, self.price_list, self.quantity_list = [], [], []
        self.products = [
            product_1.item_dictionary,
            product_2.item_dictionary
        ]  # Make list of item dictionaries

    for i in self.products:
        self.identification.append(i['ID: '])
        self.price_list.append(i['Price: '])
        self.quantity_list.append(i['Quantity: '])
        # Make unique lists of ID, Price, and Quantity

    print(sum(self.price_list))


product_1 = Product(32, 23, 2)
product_2 = Product(23, 65, 3)


inventory_1 = Inventory()
Source Link
thesolidmoose
  • 159
  • 2
  • 3
  • 9

Simple Product Inventory Project - Python

The goal: "Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an inventory class which keeps track of various products and can sum up the inventory value."

I figured out how to get a list of dictionaries, and then add up the price. My output isn't pretty, but before I continue, I would simply like general critique.

 class Product:
    def __init__(self, i, p, q):
        self.identification = i
        self.price = p
        self.quantity = q
        self.item_dictionary = {'ID: ': self.identification, 'Price: ': self.price, 'Quantity: ': self.quantity}


class Inventory:
    def __init__(self):
        self.identification, self.price_list, self.quantity_list = [], [], []
        self.products = [
            product_1.item_dictionary,
            product_2.item_dictionary
        ]  # Make list of item dictionaries

    for i in self.products:
        self.identification.append(i['ID: '])
        self.price_list.append(i['Price: '])
        self.quantity_list.append(i['Quantity: '])
        # Make unique lists of ID, Price, and Quantity

    print(sum(self.price_list))


product_1 = Product(32, 23, 2)
product_2 = Product(23, 65, 3)


inventory_1 = Inventory()