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;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.