Problem description: A renowned manufacturer wants a software to keep track of i
ID: 2249577 • Letter: P
Question
Problem description:
A renowned manufacturer wants a software to keep track of inventory of its products. Products have a name, type, quantity in stock and cost. This information about each product will have to be reported by the software. Inventory will consist of a collection of products. Inventory manager (user) should be able to specify the number of products to be added to the inventory, add products to the inventory, get products from the inventory, remove products from the inventory, find the number of laptops, servers and desktops in the inventory. Inventory manager should also be able to find the computer with the maximum cost and see its details.
Project Test Cases Worksheet
Given the problem description, our goal is to identify all the test cases that are needed to fully test our program. For each of this functionality, what values will you test your program with to ensure that it performs those functions/tasks correctly? Complete the following table. A sample value is provided to you for reference:
Task/Method Name and description
Test values
Expected Output
createInventory(): Specify number of products to add to the inventory
0
10
-10
Inventory will consist of 0 items
Inventory will consist of 10 items
ERROR. An inventory of negative size cannot be created.
Task/Method Name and description
Test values
Expected Output
createInventory(): Specify number of products to add to the inventory
0
10
-10
Inventory will consist of 0 items
Inventory will consist of 10 items
ERROR. An inventory of negative size cannot be created.
Explanation / Answer
#include <iostream>
using namespace std;
# define MAX_NUM_PRODUCTS 100
class product_class
{
private:
char *name;
int quantity;
int cost;
public:
int add(int quantity_to_be_added)
{
quantity=quantity+quantity_to_be_added;
return quantity;
}
int remove(int quantity_to_be_removed)
{
if(quantity<quantity_to_be_removed)
{
cout<<"Existing quantity is less than the requested quantity to remove";
return quantity;
}
else
{
quantity_to_be_removed=quantity-quantity_to_be_removed;
return quantity;
}
}
int get_quantity()
{
if(quantity<0)
return 0;
else
return quantity;
}
};
class inventory_class{
private:
int num_products;
class product_class product[MAX_NUM_PRODUCTS];
public:
void createInventory(int a)
{
if(a>=0)
{
num_products=a;
cout<<"Inventory will consist of "<<get_num_products()<<" items ";
}
else
{
cout<<"ERROR. An inventory of negative size cannot be created"<<a<<" ";
}
}
void add_num_products(int a)
{
num_products=num_products+a;
}
void remove_num_products(int a)
{
if(num_products>a)
num_products=num_products-a;
else
cout<<"Number of products are less than "<<a;
}
int get_num_products()
{
return num_products;
}
};
int main() {
class inventory_class inventory;
inventory.createInventory(0);
inventory.createInventory(10);
inventory.createInventory(-10);
// your code goes here
return 0;
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.