Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I am in the second semester of foundational computer science, I am workin

ID: 649110 • Letter: H

Question

Hello, I am in the second semester of foundational computer science, I am working on a "programming assignment" and am a bit stuck. Now bear in mind I am only posting a couple of the functions there are various others. Most importantly there is another class called "Product" that stores a Product Name, a Quantity, a Price and a Locator (box 1, ect.)

I am just having some trouble sorting things out any advice would help tremendously.

ProductInventory:

When a product inventory object is created, it should dynamically allocate an array of Product, using a constructor parameter to specify the size. (You should also implement a destructor). You should implement the following operations over the small store inventory:

addProduct: takes a product and adds it to the inventory. If the inventory is full, it should call the resize function first (see below). If a product with the same name and locator is already in the inventory, the add should fail and return false. If the quantity or price are invalid, it should fail and return false.

resize: internal function that doubles the size of the inventory array . Allocates a new array, and copies all the existing products to it. Be sure to clean up

Explanation / Answer

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>


class product
{
public:
   product(int n)
   {
       string inventory[n];
   }
   void add(char pro[20], int c)
   {
       inventory[c] = pro;
       cout<<"Product Added";
   }
};

void main()
{
   char p[20], ans ='y';
   int c=0;
   product o(10);

   while (ans=='y')
   {
       cout<<"Enter product";
       cin>>p;
       o.add(p,c)
       c++;
       cout<<"Want to add new Product";
       cin>>ans;
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote