Advertisement
Guest User

jva

a guest
Dec 11th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. // ===== Code from file InventoryTag.java =====
  2. public class InventoryTag {
  3. private int quantityRemaining;
  4.  
  5. public InventoryTag() {
  6. quantityRemaining = 0;
  7. }
  8.  
  9. public int getQuantityRemaining() {
  10. return quantityRemaining;
  11. }
  12.  
  13. public void addInventory(int numItems) {
  14. if (numItems > 10) {
  15. quantityRemaining = quantityRemaining + numItems;
  16. }
  17. }
  18. }
  19. // ===== end =====
  20.  
  21. // ===== Code from file CallInventoryTag.java =====
  22. import java.util.Scanner;
  23.  
  24. public class CallInventoryTag {
  25. public static void main (String [] args) {
  26. Scanner scnr = new Scanner(System.in);
  27. InventoryTag redSweater = new InventoryTag();
  28. int sweaterShipment;
  29. int sweaterInventoryBefore;
  30.  
  31. sweaterInventoryBefore = redSweater.getQuantityRemaining();
  32. sweaterShipment = scnr.nextInt();
  33.  
  34. System.out.println("Beginning tests.");
  35.  
  36. // FIXME add unit test for addInventory
  37.  
  38. if(sweaterInventoryBefore < 10 && ){
  39. System.out.println(" UNIT TEST FAILED: addInventory()");
  40. }else{
  41. redSweater.addInventory(sweaterShipment);
  42. }
  43. /* Your solution goes here */
  44.  
  45. System.out.println("Tests complete.");
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement