// An ArrayList is used to manage the list of Particles class ParticleSystem { ArrayList particles; // An arraylist for all the particles PVector origin; // An origin point for where particles are birthed ParticleSystem(int num, PVector v) { particles = new ArrayList(); // Initialize the arraylist origin = v.get(); // Store the origin point for (int i = 0; i < num; i++) { particles.add(new Particle(origin)); // Add "num" amount of particles to the arraylist } } void run() { // Cycle through the ArrayList using Iterator we are deleting Iterator it = particles.iterator(); while (it.hasNext()) { Particle p = it.next(); p.run(); if (p.isDead()) { it.remove(); } } } void addParticle() { particles.add(new Particle(origin)); } void addParticle(Particle p) { particles.add(p); } // A method to test if the particle system still has particles boolean dead() { if (particles.isEmpty()) { return true; } else { return false; } } }