Answered step by step
Verified Expert Solution
Question
1 Approved Answer
result = vm.checkStock(Kitkat Chunky Bar); assertEquals(Kitkat Chunky Bar (4), result); result = vm.checkStock(); assertEquals(Stock: Coke (4), Orange Juice (4), Kitkat Chunky Bar (4), Lay's Classic
result = vm.checkStock("Kitkat Chunky Bar"); assertEquals("Kitkat Chunky Bar (4)", result); result = vm.checkStock(); assertEquals("Stock: Coke (4), Orange Juice (4), Kitkat Chunky Bar (4), Lay's Classic Chips (8)", result); /* * Remove stock of Lay's Classic Chips */ vm.dispense("Lay's Classic Chips", 4); // this changes the status result = vm.checkStatus(); assertEquals("Product removed: Lay's Classic Chips (4)", result); // Notice the space after the colon ":" and result = vm.checkStock("Lay's Classic Chips"); assertEquals("Lay's Classic Chips (4)", result); result = vm.checkStock(); assertEquals("Stock: Coke (4), Orange Juice (4), Kitkat Chunky Bar (4), Lay's Classic Chips (4)", result); /* * Remove stock of an invalid product */ vm.dispense("M & M's Chocoloate Bag", 4); // this changes the status result = vm.checkStatus(); assertEquals("Invalid product: M & M's Chocoloate Bag", result); // Notice the space between colon (:) and the result = vm.checkStock("M & M's Chocoloate Bag"); assertEquals("Invalid product: M & M's Chocoloate Bag", result); // Notice the space between colon (:) and the result = vm.checkStock(); // stock of existing products remain the same assertEquals("Stock: Coke (4), Orange Juice (4), Kitkat Chunky Bar (4), Lay's Classic Chips (4)", result); } /* * Additional tests related to using a vending machine */ @Test public void test_VendingMachine_04() { VendingMachine vm = new VendingMachine(); /* You may add additional, similar tests on other products */ vm.add("Kitkat Chunky Bar", 7); assertEquals("Kitkat Chunky Bar (7)", vm.checkStock("Kitkat Chunky Bar")); assertEquals("Stock: Coke (0), Orange Juice (0), Kitkat Chunky Bar (7), Lay's Classic Chips (0)", vm.checkStoc vm.dispense("Kitkat Chunky Bar", 3); assertEquals("Kitkat Chunky Bar (4)", vm.checkStock("Kitkat Chunky Bar")); assertEquals("Stock: Coke (0), Orange Juice (0), Kitkat Chunky Bar (4), Lay's Classic Chips (0)", vm.checkStoc vm.add("Kitkat Chunky Bar", 5); assertEquals("Kitkat Chunky Bar (9)", vm.checkStock("Kitkat Chunky Bar")); assertEquals("Stock: Coke (m), Orange Juice (0), Kitkat Chunky Bar (9), Lay's Classic Chips (0)", vm.checkStoc } } * Add stock of Lay's Classic Chips */ vm.add("Lay's Classic Chips", 5); // this changes the status result = vm.checkStatus(); assertEquals("Product added: Lay's Classic Chips (5)", result); // Notice the space after the colon ":" and bef result = vm.checkStock("Lay's Classic Chips"); assertEquals("Lay's Classic Chips (5)", result); result = vm.checkStock(); assertEquals("Stock: Coke (5), Orange Juice (5), Kitkat Chunky Bar (5), Lay's Classic Chips (5)", result); Add stock of an invalid product */ vm.add("Maltesers Chocolate", 4); // this changes the status result = vm.checkStatus(); assertEquals("Invalid product: Maltesers Chocolate", result); // Notice the space between colon (:) and the inv result = vm.checkStock("Maltesers Chocolate"); assertEquals("Invalid product: Maltesers Chocolate", result); // Notice the space between colon (:) and the inv result = vm.checkStock(); // stock of existing products remain the same assertEquals("Stock: Coke (5), Orange Juice (5), Kitkat Chunky Bar (5), Lay's Classic Chips (5)", result); } /* * Tests related to reducing stock from the vending machine */ @Test public void test_VendingMachine_03() { VendingMachine vm = new VendingMachine(); /* * Add stocks of products vm.add("Coke", 5); vm.add("Orange Juice", 6); vm.add("Kitkat Chunky Bar", 7); vm.add("Lay's Classic Chips", 8); String result = vm.checkStock(); assertEquals("Stock: Coke (5), Orange Juice (6), Kitkat Chunky Bar (7), Lay's Classic Chips (8)", result); /* * Remove stock of Coke */ vm.dispense("Coke", 1); // this changes the status result = vm.checkStatus(); assertEquals("Product removed: Coke (1)", result); // Notice the space after the colon ":" and before the openi result = vm.checkStock("Coke"); assertEquals("Coke (4)", result); result = vm.checkStock(); accor+Caualcistocki Coke A Orange Juice (6) Vat Chunky Bar (7) Tavle clacete Chine Toll racul+. result = vm.checkStock("Kitkat Chunky Bar"); assertEquals("Kitkat Chunky Bar (4)", result); result = vm.checkStock(); assertEquals("Stock: Coke (4), Orange Juice (4), Kitkat Chunky Bar (4), Lay's Classic Chips (8)", result); /* * Remove stock of Lay's Classic Chips */ vm.dispense("Lay's Classic Chips", 4); // this changes the status result = vm.checkStatus(); assertEquals("Product removed: Lay's Classic Chips (4)", result); // Notice the space after the colon ":" and result = vm.checkStock("Lay's Classic Chips"); assertEquals("Lay's Classic Chips (4)", result); result = vm.checkStock(); assertEquals("Stock: Coke (4), Orange Juice (4), Kitkat Chunky Bar (4), Lay's Classic Chips (4)", result); /* * Remove stock of an invalid product */ vm.dispense("M & M's Chocoloate Bag", 4); // this changes the status result = vm.checkStatus(); assertEquals("Invalid product: M & M's Chocoloate Bag", result); // Notice the space between colon (:) and the result = vm.checkStock("M & M's Chocoloate Bag"); assertEquals("Invalid product: M & M's Chocoloate Bag", result); // Notice the space between colon (:) and the result = vm.checkStock(); // stock of existing products remain the same assertEquals("Stock: Coke (4), Orange Juice (4), Kitkat Chunky Bar (4), Lay's Classic Chips (4)", result); } /* * Additional tests related to using a vending machine */ @Test public void test_VendingMachine_04() { VendingMachine vm = new VendingMachine(); /* You may add additional, similar tests on other products */ vm.add("Kitkat Chunky Bar", 7); assertEquals("Kitkat Chunky Bar (7)", vm.checkStock("Kitkat Chunky Bar")); assertEquals("Stock: Coke (0), Orange Juice (0), Kitkat Chunky Bar (7), Lay's Classic Chips (0)", vm.checkStoc vm.dispense("Kitkat Chunky Bar", 3); assertEquals("Kitkat Chunky Bar (4)", vm.checkStock("Kitkat Chunky Bar")); assertEquals("Stock: Coke (0), Orange Juice (0), Kitkat Chunky Bar (4), Lay's Classic Chips (0)", vm.checkStoc vm.add("Kitkat Chunky Bar", 5); assertEquals("Kitkat Chunky Bar (9)", vm.checkStock("Kitkat Chunky Bar")); assertEquals("Stock: Coke (m), Orange Juice (0), Kitkat Chunky Bar (9), Lay's Classic Chips (0)", vm.checkStoc } } * Add stock of Lay's Classic Chips */ vm.add("Lay's Classic Chips", 5); // this changes the status result = vm.checkStatus(); assertEquals("Product added: Lay's Classic Chips (5)", result); // Notice the space after the colon ":" and bef result = vm.checkStock("Lay's Classic Chips"); assertEquals("Lay's Classic Chips (5)", result); result = vm.checkStock(); assertEquals("Stock: Coke (5), Orange Juice (5), Kitkat Chunky Bar (5), Lay's Classic Chips (5)", result); Add stock of an invalid product */ vm.add("Maltesers Chocolate", 4); // this changes the status result = vm.checkStatus(); assertEquals("Invalid product: Maltesers Chocolate", result); // Notice the space between colon (:) and the inv result = vm.checkStock("Maltesers Chocolate"); assertEquals("Invalid product: Maltesers Chocolate", result); // Notice the space between colon (:) and the inv result = vm.checkStock(); // stock of existing products remain the same assertEquals("Stock: Coke (5), Orange Juice (5), Kitkat Chunky Bar (5), Lay's Classic Chips (5)", result); } /* * Tests related to reducing stock from the vending machine */ @Test public void test_VendingMachine_03() { VendingMachine vm = new VendingMachine(); /* * Add stocks of products vm.add("Coke", 5); vm.add("Orange Juice", 6); vm.add("Kitkat Chunky Bar", 7); vm.add("Lay's Classic Chips", 8); String result = vm.checkStock(); assertEquals("Stock: Coke (5), Orange Juice (6), Kitkat Chunky Bar (7), Lay's Classic Chips (8)", result); /* * Remove stock of Coke */ vm.dispense("Coke", 1); // this changes the status result = vm.checkStatus(); assertEquals("Product removed: Coke (1)", result); // Notice the space after the colon ":" and before the openi result = vm.checkStock("Coke"); assertEquals("Coke (4)", result); result = vm.checkStock(); accor+Caualcistocki Coke A Orange Juice (6) Vat Chunky Bar (7) Tavle clacete Chine Toll racul+
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started