Answer:
kindly check explainations for code
Explanation:
Header files
#include <iostream>
using namespace std;
// define class InventoryTag
class InventoryTag
{
public:
// constructor
InventoryTag();
// declare functions
int getQuantityRemaining() const;
void addInventory(int numItems);
private:
// declare a variable
int quantityRemaining;
};
InventoryTag::InventoryTag()
{
quantityRemaining = 0;
}
// function definition
int InventoryTag::getQuantityRemaining() const
{
return quantityRemaining;
}
// function definition
void InventoryTag::addInventory(int numItems)
{
if (numItems > 10)
{
quantityRemaining = quantityRemaining + numItems;
}
}
// main function
int main()
{
// create an object for class InventoryTag
InventoryTag redSweater;
// Declare variables
int sweaterShipment = 0;
int sweaterInventoryBefore = 0;
// Call getQuantityRemaining()function
sweaterInventoryBefore =
redSweater.getQuantityRemaining();
// Assign a value to variable
sweaterShipment =25;
cout << "Beginning tests." << endl;
// FIXME add unit test for addInventory
/* Your solution goes here */
// Call addInventory() function
redSweater.addInventory(sweaterShipment);
// Check whether the result is expected result
// or not
if (redSweater.getQuantityRemaining() !=
sweaterShipment + sweaterInventoryBefore)
{
// Print error message
cout << " UNIT TEST FAILED: addInventory()"
<< endl;
}
cout << "Tests complete." << endl;
system("pause");
return 0;
}