#ifndef PARTICLE_H #define PARTICLE_H #include "rcpointe.h" #include "darray.h" #include #include #pragma hdrstop class Particle { public: Particle(){}//used when generating place holders in clone chooser Particle(int i,int j, int x, int y) :where(x,y) {startTime = i;endTime = j;} Particle(const Particle &p) {startTime = p.startTime;endTime = p.endTime;} static Particle* genParticle(Particle *p,int ctime,int x, int y){return p->clone(ctime,x,y);} static Particle* genParticle(const Particle *p){return p->clone(p);} virtual void show(TDC *dc);// used to show each type of particle int check(int nowTime){return nowTime != endTime;} virtual void explode(TDC *); // virtual function called for each type of particle protected: void explode(TDC *,int); // called by the particle explosions since need access to "where" void show(TDC*,TColor); //This is called from the various virtual functions because you need access to "where" private: virtual Particle* clone(int,int,int)const=0; virtual Particle* clone(const Particle*)const =0; int startTime; int endTime; TPoint where; }; class Alfa :public Particle { public: Alfa(){} Alfa(int ctime,int x, int y):Particle(ctime, ctime +5,x,y){} Alfa(const Particle &c):Particle(c){} virtual void show(TDC *dc); virtual void explode(TDC *); private: virtual Particle* clone(int i,int x, int y)const{Alfa *t =new Alfa(i,x,y);return t;} virtual Particle* clone(const Particle *p)const {Alfa *t= new Alfa(*p); return t;} }; class Beta : public Particle { public: Beta(){} Beta(int ctime,int x, int y):Particle(ctime, ctime +10,x,y){} Beta(const Particle &c):Particle(c){} virtual void show(TDC *dc); virtual void explode(TDC *); private: virtual Particle* clone(int i,int x, int y)const{Beta *t= new Beta(i,x,y);assert(t!=NULL);return t;} virtual Particle* clone(const Particle *p)const {Beta *t= new Beta(*p); return t;} }; typedef RcPointer PPtr; typedef Array Parray; class ParticleList { public: void insert(PPtr p); void update(TWindow*,int); void show(TDC *); private: void deleteAt(int); Parray data; int active; }; #endif