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
Which type of unshielded twisted pair (UTP) is commonly used in Ethernet 10BASE-T networks, which carry data at a rate of 10 Mbp
tino4ka555 [31]

Answer:

Category 3 (CAT3) Unshielded Twisted Pair cable

Explanation:

A Category 3 (CAT3) Unshielded Twisted Pair cable is a cable that makes use of the conductivity of copper to transmit data and power. These cables are an older standard for Ethernet cables and can handle data speeds of up to 10mbps.The succeeding standard for Ethernet cables include CAT5 which has speeds of up to 100 mbps, CAT 3 is mostly used in applications where speed is not of great importance such as in PBXs and VoIP telephone systems.

6 0
3 years ago
In what decade was photography invented? the 1800s the 1820s the 1840s the 1860s
frutty [35]

Answer:

In the year 1820's

It is B

4 0
3 years ago
What happens when there is a data fail?
Korvikt [17]
Data loss also sets back productivity timelines and can cause you to lose customers if it is accompanied by security breaches
7 0
3 years ago
Read 2 more answers
A form of artificial intelligence that can perform many complex, _______ tasks. Select one: a. serialized b. repetitive c. non-r
Tanya [424]

Answer:

The correct answer is letter "C": non-repetitive.

Explanation:

Artificial Intelligence (AI) refers to all efforts mankind has made to program computer systems in a way they can interact as humans and imitate their actions. There are different types of AI based on their likeness to humankind. In such a scenario, AI can be reactive (respond to stimuli), self-aware (awareness capabilities), limited memory (learns to improve) or theory of mind (understands other intelligencies).

<em />

<em>All those types of AI are based on non-repetitive tasks that can perform different complex processes.</em>

6 0
4 years ago
Write the definition of a function named count that reads all the strings remaining to be read in standard input and returns the
spayn [35]

Answer:

The function written in C++

int str(string word) {

int count = 1;

for(int i =0; i<word.length();i++) {

 if(word[i] == ' ') {

  count++;

 }

}

return count;

}

Explanation:

This line defines the function

int str(string word) {

This line initializes count to 1

int count = 1;

This line iterates through the input string

for(int i =0; i<word.length();i++) {

This line checks for blank space

 if(word[i] == ' ') {

Variable count is incremented to indicate a word count

  count++;

 }

}

return count;

}

<em>See attachment for full program</em>

Download cpp
8 0
3 years ago
Other questions:
  • 2.24 Write the relevant Python expression or statement, involving a list of numbers lst and using list operators and methods for
    11·1 answer
  • You are given two variables, already declared and assigned values, one of type double, named price, containing the price of an o
    7·1 answer
  • Please write a complete program to calculate monthly payment given
    15·1 answer
  • Which is a good guideline to follow when looking for research material on the Internet?
    10·2 answers
  • which of the following are available options when importing a photoshop document into adobe illustrator
    7·1 answer
  • When Jimmy Fallon is outside the White House, his persona is mostly O A. humble O B. stern O c. gloomy O D. wild​
    9·1 answer
  • Boolean, integer, string, and float are examples of:
    9·2 answers
  • Join me in mincraft I will tell you my code if you want to join and the mincraft I play is mincraft education edition
    8·2 answers
  • .
    5·1 answer
  • Explain the role and importance of ict in daily life ?​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!