Question
Need help filling in the BagContents: For the testBagContents() method, create a DisplayCollection the same way you did for the testBagSize() method. In this test,
Need help filling in the BagContents:
For the testBagContents() method, create a DisplayCollection the same way you did for the testBagSize() method. In this test, we want to ensure that every String the bag contains is one of the four legal strings: "blue square", "red square", "blue circle", or "red circle" in the STRINGS constant. Make sure to use the STRINGS constant for testing!
Create a loop which iterates over the bags content. Inside the loop, call the bags remove() method to pull out a String. Assert that every String is one of the four legal strings using assertTrue(boolean condition). When all of your tests pass, youre ready to move on to the final phase!
/** * */ package project1;
import student.TestCase; /** * @author User1 * */ public class DisplayCollectionTest extends TestCase { /** * Setup left intentionally blank */ public void setup() { } public void testBagContents() {
DisplayCollection testBagContents = new DisplayCollection(); int size = testbagContents.getItemBag().getCurrentSize(); Error testbagContents cant be resolved } public void testBagSize() { for (int i = 0; i<= 20; i++) { DisplayCollection testBag = new DisplayCollection(); int size = testBag.getItemBag().getCurrentSize(); System.out.println(size); assertTrue(size <= 15 && size >=5); assertFalse(size < 5); assertFalse(size > 15); } }
}
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