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
A counter is a tool used to measure the number of times people visit a Web site. true or false?
Liono4ka [1.6K]

True.

It doesn't measure unique users, so you can just hit refresh and the counter keeps going up...

5 0
3 years ago
Se que esto no tiene que ver con ninguna materia pero porque en instagram me sale por ejemplo que han visto 10 personas Y cuando
abruzzese [7]

Answer:

Bueno, realmente no entendí lo que dijiste, pero, ¿podrías decirlo donde puedo ayudarte?

7 0
3 years ago
A soft drink company recently surveyed 12,467 of its customers and found that approximately 14 percent of those surveyed purchas
Mnenie [13.5K]

Given Information:

Total number of customers = 12,467

Customers who purchase one or more energy drinks per week = 14%

Customers who prefer citrus flavored energy drinks = 64% of customers who purchase one or more energy drinks per week

Required Information:

1. the approximate number of customers in the survey who purchase one or more energy drinks per week

2. the approximate number of customers in the survey who prefer citrus flavored energy drinks

Code with Explanation:

#include <iostream>

using namespace std;

int main()

{

   int customers = 12467;  // total no. of customers given

   int buy_drink;  // to store the number of customers who buy one or more energy drinks per week

   int citrus_drink;  // to store the number of customers who prefer citrus flavored energy drinks

 

   buy_drink = customers*0.14;  // multiply total number of customers with the % of customers who buy energy drinks

   citrus_drink = buy_drink*0.64;  // multiply no. of customers who buy one or more energy drinks per week with % of customers who prefer citrus flavor

// display the results calculated above

   cout<<"Total number of customers: "<<customers<<endl;

   cout<<"Number of customers who buy one or more drinks per week: "<<buy_drink<<endl;

   cout<<"Number of customers who prefer citrus flavored drinks per week: "<<citrus_drink<<endl;

   return 0;

}

Output:

Total number of customers: 12467

Number of customers who buy one or more drinks per week: 1745

Number of customers who prefer citrus flavored drinks per week: 1116

7 0
3 years ago
This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by
stira [4]

Answer:

Here is the C program:

#include <stdio.h>  //to use input output functions

int main(void) {   //start of main function

 int arrowBaseHeight = 0;  //stores value for arrow base height

int  arrowBaseWidth = 0;  //stores value for arrow base width

 int arrowHeadWidth = 0 ;  //stores value for arrow head width

 int i, j;  //to traverse through the rows and columns

 printf("Enter arrow base height:\n");  //prompts user to enter arrow base height value

 scanf("%d", &arrowBaseHeight);  //reads input value of arrow base height

 printf("Enter arrow base width:\n");  //prompts user to enter arrow base width value

 scanf("%d", &arrowBaseWidth);  //reads input value of arrow base width

 while (arrowHeadWidth <= arrowBaseWidth)  {   //iterates as long as the value of arrowHeadWidth is less than or equals to the value of arrowBaseWidth  

     printf("Enter arrow head width:\n");   //prompts user to enter arrow head width value

     scanf("%d", &arrowHeadWidth);   //reads input value of arrow head width

     printf("\n"); }

 for (i = 0; i < arrowBaseHeight; i++)    {   //iterates through rows

     for (j = 0; j < arrowBaseWidth; j++)  {   //iterates through columns

         printf("*");       }   //prints asterisks

     printf("\n");   }   //prints a new line

 for (i = arrowHeadWidth; i > 0; i--)    {   //loop for input length

     for (j = i; j > 0; j--)        {   //iterates for triangle ( to make arrow head)

         printf("*");       }   //prints asterisks

     printf("\n");   }  } //prints new line

Explanation:

The program asks to enter the height of the arrow base, width of the arrow base and the width of arrow head. When asking to enter the width of the arrow head, a condition is checked that the arrow head width arrowHeadWidth should be less than or equal to width of arrow base arrowBaseWidth. The while loop keeps iterating until the user enters the arrow head width larger than the value of arrow base width.  

The loop is used to output an arrow base of height arrowBaseHeight.

The nested loop is being used which as a whole outputs an arrow base of width arrowBaseWidth. The inner loop draws the stars and forms the base width of the arrow, and the outer loop iterates a number of times equal to the height of the arrow.

The last nested loop is used to output an arrow head of width arrowHeadWidth. The inner loop forms the arrow head and prints the stars needed to form an arrow head.  

The screenshot of output is attached.

8 0
3 years ago
Help! I turned on my computer and this screen came on out of nowhere, I don't know what to do to fix it.
babunello [35]

Here are the steps I would do:

Do a "hard" power off. Hold the power key until the screen turns off. Wait 10 seconds. Turn it on. If it still shows the screen... then i'm not sure.

The error is occurring because it has nothing to boot off of. It's probably something wrong with your hardware. The instructions say for you to insert a "boot disk" and press any key.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Draw the cache tables and the state of all bits within them. Suppose you have a 16 byte cache with 2 byte long cachelines that i
    6·1 answer
  • What component of a computer system holds the operating system when the computer is not running
    6·2 answers
  • Are psn cd keys region free? If not where can I get one in my region?
    5·2 answers
  • A blank is the full web Address for particular website<br> (Computer technology)
    14·1 answer
  • "Your friend is having a birthday and you want to create a slide-show presentation with pictures of her that you have saved on y
    15·1 answer
  • PLEASE HELP :(
    12·1 answer
  • Write a program that prompts the user to enter their name store this value in a variable called name Prompt the user for their c
    10·1 answer
  • The most common clefs for high notes are what?
    6·2 answers
  • You are building a computer from spare parts in the office. You build the computer and realize you have several different types
    5·1 answer
  • you are investigating the use of website and url content filtering to prevent users from visiting certain websites. which benefi
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!