refillPool2 method

void refillPool2(
  1. double percentage
)

Implementation

void refillPool2(double percentage) {
  int portionOfCapacity = (desiredCapacity * percentage).toInt();

  if (portionOfCapacity < 1) {
    portionOfCapacity = 1;
  } else if (portionOfCapacity > desiredCapacity) {
    portionOfCapacity = desiredCapacity;
  }

  for (int i = 0; i < portionOfCapacity; i++) {
    this.objects[i] = modelObject.instantiate();
  }
  objectsPointer = portionOfCapacity - 1;
}