149k views
1 vote
#include using namespace std; class InventoryTag { public: InventoryTag(); int getQuantityRemaining() const; void addInventory(int numItems); private: int quantityRemaining; }; InventoryTag::InventoryTag() { quantityRemaining = 0; } int InventoryTag::getQuantityRemaining() const { return quantityRemaining; } void InventoryTag::addInventory(int numItems) { if (numItems > 10) { quantityRemaining = quantityRemaining + numItems; } } int main() { InventoryTag redSweater; int sweaterShipment; int sweaterInventoryBefore; sweaterInventoryBefore = redSweater.getQuantityRemaining(); cin >> sweaterShipment; cout << "Beginning tests." << endl; // FIXME add unit test for addInventory /* Your solution goes here */ cout << "Tests complete." << endl; return 0; }

User MattW
by
4.5k points

1 Answer

1 vote

Answer:

Step-by-step explanation:

This is an assignment for a C++ programming class.

#include <iostream>

using namespace std;

class InventoryTag {

public:

InventoryTag();

int getQuantityRemaining() const;

void addInventory(int numItems);

private:

int quantityRemaining;

};

InventoryTag::InventoryTag() {

quantityRemaining = 0;

}

int InventoryTag::getQuantityRemaining() const {

return quantityRemaining;

}

void InventoryTag::addInventory(int numItems) {

if (numItems > 10) {

quantityRemaining = quantityRemaining + numItems;

}

}

int main() {

InventoryTag redSweater;

int sweaterShipment;

int sweaterInventoryBefore;

sweaterInventoryBefore = redSweater.getQuantityRemaining();

cin >> sweaterShipment;

cout << "Beginning tests." << endl;

// FIXME add unit test for addInventory

/* Your solution goes here */

redSweater.addInventory(sweaterShipment);

if (redSweater.getQuantityRemaining() != sweaterShipment){

cout << " UNIT TEST FAILED: addInventory()\\";

}

User Mayur Prajapati
by
4.6k points