ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 10 Weeks Ago, 5 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 23 May 2017 My Price 8.00

Write a unit test for addInventory

Write a unit test for addInventory(). Call redSweater.addInventory() with parameter sweaterShipment. Print the shown error if the 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.

 

// ===== Code from file InventoryTag.java =====

public class InventoryTag {

   private int quantityRemaining;

 

   public InventoryTag() {

      quantityRemaining = 0;

   }

 

   public int getQuantityRemaining() {

      return quantityRemaining;

   }

 

   public void addInventory(int numItems) {

      if (numItems > 10) {

         quantityRemaining = quantityRemaining + numItems;

      }

      return;

   }

}

// ===== end =====

 

// ===== Code from file CallInventoryTag.java =====

public class CallInventoryTag {

   public static void main (String [] args) {

      InventoryTag redSweater = new InventoryTag();

      int sweaterShipment = 0;

      int sweaterInventoryBefore = 0;

 

      sweaterInventoryBefore = redSweater.getQuantityRemaining();

      sweaterShipment = 25;

 

      System.out.println("Beginning tests.");

 

      // FIXME add unit test for addInventory

 

      /* Your solution goes here  */

 

      System.out.println("Tests complete.");

 

      return;

   }

}

// ===== end =====

Answers

(11)
Status NEW Posted 23 May 2017 02:05 AM My Price 8.00

-----------

Not Rated(0)