1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mariarad [96]
3 years ago
9

Write a unit test for addInventory(). Call redSweater.addInventory() with parameter sweaterShipment. Print the shown error if th

e subsequent quantity is incorrect. Sample output for failed unit test given initial quantity is 10 and sweaterShipment is 50:
Beginning tests.
UNIT TEST FAILED: addInventory()
Tests complete.
Note: UNIT TEST FAILED is preceded by 3 spaces.

#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 = 0;
int sweaterInventoryBefore = 0;

sweaterInventoryBefore = redSweater.getQuantityRemaining();
sweaterShipment = 25;

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

// FIXME add unit test for addInventory

/* Your solution goes here */

cout << "Tests complete." << endl;

return 0;
}
Computers and Technology
2 answers:
Serhud [2]3 years ago
5 0

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;

}

zavuch27 [327]3 years ago
5 0

Answer:

redSweater.addInventory(sweaterShipment);

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

System.out.println("   UNIT TEST FAILED: addInventory()");

}

Explanation:

The if statement sets a condition for the unit test. If the condition isn't met then it prints the unit failed statement. Also, the answer above is kinda right but has lots of extra stuff in the code. Remember to have 3 spaces before the unit failed statement, 1 test will pass but the last one won't.

You might be interested in
Consider the following code segment:
horrorfan [7]

Answer:

13333333333333333333333fv mvfdmv mfv fmv f mf vmf f vfmvnfmvnmnvmfnvmnvmnv3Explanation:

6 0
3 years ago
This is an example of what type of formula?
slamgirl [31]

Answer:

Average

Explanation:

The term 'average' refers to the 'middle' or 'central' point. When used in mathematics, the term refers to a number that is a typical representation of a group of numbers (or data set). Averages can be calculated in different ways - this page covers the mean, median and mode.

3 0
2 years ago
Assuming you have a TCF free student checking account, how many maximum overdraft fees can you incur in one day?
kodGreya [7K]

Answer:

8

Explanation:

7 0
3 years ago
What is the definition of Microsoft Operating System?<br>​
MaRussiya [10]

Answer:

Operating system designed and produced by Microsoft Corporation. Similar to other operating systems, Windows makes a computer system user-friendly by providing a graphical display and organizing information so that it can be easily accessed.

Explanation:

6 0
4 years ago
Read 2 more answers
Keyshia wants to add movement to her PowerPoint presentation. Which tab should she use to complete this task?
MariettaO [177]

Answer:

A on edg

Explanation:

5 0
3 years ago
Other questions:
  • How do rubrics increase learning?
    15·2 answers
  • What's a good show to watch on Netflix?
    7·1 answer
  • How to be professional in graphic design without CAD?
    5·1 answer
  • If a user wished to insert a triangle or a callout figure in a document, he or she should select the _____ option.
    8·1 answer
  • Anyone good at graphics?
    14·1 answer
  • Which of the following is the definition of registration authority ( RA)?
    10·1 answer
  • What is output? Select all that apply. c = 3 while (c &lt; 10): c = c + 2 print (c)
    6·1 answer
  • What do the Brainly points do? sorry im new here and i dont know how to internet rn .-.
    7·2 answers
  • 2. List the differences between personal
    7·2 answers
  • You have been asked to investigate a web server for possible intrusion. You identify a script with the following code. What lang
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!