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
What is the other name of iterative staatement ​
Mademuasel [1]

Answer:

An loop statement

Explanation:

An iteration statement, loop, repeatedly executes a statement, know as a loop body,until the controlling expression is false

8 0
3 years ago
1
g100num [7]
Have a look at the man page for printf:

man 3 printf
4 0
3 years ago
Read 2 more answers
What keyboard key can you press to limit the angle of the line when using the pencil tool?
leva [86]
F6,p hope that helps :)
6 0
3 years ago
Which of these conclusions supports the fact that Eclipse is categorized as an IDE?
Drupady [299]

Answer:

The user must specify the programming language he or she wants to use.

Explanation:

6 0
3 years ago
Write a program whose input is two integers. Output the first integer and subsequent increments of 10 as long as the value is le
Lubov Fominskaja [6]

Answer:

import java.util.Scanner;

public class TestClock {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter two integer numbers");

       int num1 = in.nextInt();

       int num2 = in.nextInt();

       int newSum=num1+10;

       System.out.println("The first number is "+num1);

       do{

          System.out.println(newSum);

          newSum +=10;

       }while (newSum <=num2);

   }

}

Explanation:

Using Java Programming language

  1. Prompt user for the two inputs and save them as num1 and num2(Using the scanner class)
  2. Create a new Variable newSum = num1+10
  3. Create a do...while loop to continually print the value of newSum, and increment it by 10 while it is less or equal to num2
3 0
3 years ago
Other questions:
  • Answer this question please
    6·1 answer
  • * Declare a variablecalled "car" of type "Car", and initialise its value to a new instance of the "Car"class.
    9·1 answer
  • 1. What does it mean to say that a country’s land area is positively correlated with its population?
    12·2 answers
  • which one of these steps describe saving a newly created file. click on the save icon. minimize the file. name the file. select
    12·2 answers
  • Adele’s mother owns a Daycare and she wants to learn all about this business, to help her mom and own it one day. Which CTSO sho
    9·1 answer
  • Which type of memory helps in reading as well as writing data?
    13·1 answer
  • Henry went to an IT software company for an interview he was offered a position in lower level management which positions could
    11·1 answer
  • "You have installed a point-to-point connection using wireless bridges and Omni directional antennas between two buildings. The
    8·1 answer
  • Which is a basic job requirement for a career in corrections services?
    13·1 answer
  • There are types of templates​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!