/// <summary> /// Конструктор класса /// </summary> public MovingParticle(int x, int y, int velocity, int[] vector, char c, ParticleFactory factory) { this.x = x; this.y = y; this.velocity = velocity; this.vector = vector; particle = factory.GetParticle(c); }
/// <summary> /// Точка входа /// </summary> static void Main() { // Создаём новую фабрику частиц, объявляем массив двигающихся частиц ParticleFactory factory = new ParticleFactory(); List <MovingParticle> moving_particles = new List <MovingParticle>(); // Заполняем массив двигающихся частиц moving_particles.Add(new MovingParticle(4, 5, 10, new int[] { 1, 3 }, 'A', factory)); moving_particles.Add(new MovingParticle(0, 0, 5, new int[] { 5, 9 }, 'A', factory)); moving_particles.Add(new MovingParticle(7, -9, 3, new int[] { 7, 3 }, 'B', factory)); moving_particles.Add(new MovingParticle(1, 5, 4, new int[] { 7, 5 }, 'A', factory)); moving_particles.Add(new MovingParticle(4, 1, 2, new int[] { 9, 3 }, 'B', factory)); moving_particles.Add(new MovingParticle(1, 1, 1, new int[] { 9, 9 }, 'B', factory)); foreach (MovingParticle moving_particle in moving_particles) { moving_particle.move(); } Console.ReadKey(); }