Hi, I am being asked to use nested loops to create instances of the class (EOHoverFrog) with states covering all possible combinatinos of the colours red and green, all visible positions (1 to 11), and all heights (0 to 6) - there are 154 combinations. All of these instances of EOHoverFrog should be added to the collection provided as the method's argument. Your method should then print to the Display Pane: "Number of EOHoverFrogs in collection = "
Basically I have no idea how to start. The only way i know of creating a new instance is EOHoverFrog f1 = new EOHoverFrog. Any clues as to how to go about it using a loop just to get me started?
I would have thought a for-each loop (=enhanced for loop) easier. Let's rewrite Fred's last example:You can see it works for colors where you are using an array. You can't use it for p because p isn't an array.
Joined: Sep 09, 2011
Firstly I want to apologise in case this doesn't work properly, I don't have internet at home yet so I'm using my phone now...
But so far I've got this
I know that isn't right because it's not compiling. First error message is “cannot find symbol - variable HashSet“ again I didn't think it was HashSet but I don't know what else to put there.
Also, where I've put .... I'm not sure what to put there. I need to add all of these instances of EOHoverFrog to collection provided as the method's argument (I don't understand that bit), and finally return the collection...oh and if I comment out where I get the first error message then I get a second one on the last line “cannot find symbol - variable populatePond“.
Joined: Sep 09, 2011
Ok I just re-read the question. My method should have a single argument, whose type should work equally well for a list, or a set, or a sorted set with elements of type EOHoverFrog. The returned collection should be of the same type. I've tried changing it to
Public static EOHoverFrog populatePond(EOHoverFrog frog), that compiles but I don't know if its actually right.
subject: using nested loops to create instances of a class