I have created this program where an array of bubble objects will be created in the constructor, and then the bubbles will float accross the canvas and once the bubbles touch each other they will disappear and reveal the words "POP!". My method called noneLeft() should return true if all the bubbles have been popped and then another method called redisplayAll() will be called and the bubbles will reset and redisplay again. However, I am not sure what to write for my if statement to return true once the last bubble has been popped. How do I write down if the last bubble in the array has been popped, then return true. Would I have to use bubbles.length?
public Mover(double width, double height, int numberOfBubbles) {
canvasWidth = width;
canvasHeight = height;
bubbles = new Bubble[numberOfBubbles];
for (int i = 0; i < numberOfBubbles; i ++){
bubbles[i] = new Bubble();
bubbles[i].showBubble(width, height);
}
count = 0;
}
public boolean noneLeft() {
if (bubbles[].isPopped() == true){
return true;
}
return false;
}
return Arrays.stream(bubbles).allMatch(x -> x.isPopped());