Exemplo n.º 1
0
        // hidden communication between planes
        public override void Communicate(AirCraftMachine plane, int x, int y)
        {
            foreach (var pl in planes)
            {
                if (pl.X == x && pl.Y == y)
                {
                    Console.WriteLine("{0} says: You can NOT fly there!", this.GetType().Name);
                    return;
                }
            }

            this.fieldCoodinates[plane.X, plane.Y] = true;
            this.fieldCoodinates[x, y] = false;
            plane.X = x;
            plane.Y = y;
            Console.WriteLine("{0} says: {1} successfully send to coordinates x:{2} - y:{3}!", this.GetType().Name, plane.Name, x, y);
        }
Exemplo n.º 2
0
        // hidden communication between planes
        public override void Communicate(AirCraftMachine plane, int x, int y)
        {
            foreach (var pl in planes)
            {
                if (pl.X == x && pl.Y == y)
                {
                    Console.WriteLine("{0} says: You can NOT fly there!", this.GetType().Name);
                    return;
                }
            }

            this.fieldCoodinates[plane.X, plane.Y] = true;
            this.fieldCoodinates[x, y]             = false;
            plane.X = x;
            plane.Y = y;
            Console.WriteLine("{0} says: {1} successfully send to coordinates x:{2} - y:{3}!", this.GetType().Name, plane.Name, x, y);
        }
Exemplo n.º 3
0
        public override void AddToControlCenter(AirCraftMachine plane)
        {
            for (int i = 0; i < fieldCoodinates.GetLength(0); i++)
            {
                for (int k = 0; k < fieldCoodinates.GetLength(1); k++)
                {
                    // search for free slot
                    if (fieldCoodinates[i, k] == true)
                    {
                        planes.Add(plane);
                        plane.X = i;
                        plane.Y = k;
                        fieldCoodinates[i, k] = false;
                        Console.WriteLine("{0} says: {1} added to our control center on coordinates x:{2} - y:{3}!", this.GetType().Name, plane.Name, plane.X, plane.Y);
                        return;
                    }
                }
            }

            Console.WriteLine("{0} says: To much traffic try to join later...", this.GetType().Name);
        }
Exemplo n.º 4
0
        public override void AddToControlCenter(AirCraftMachine plane)
        {
            for (int i = 0; i < fieldCoodinates.GetLength(0); i++)
            {
                for (int k = 0; k < fieldCoodinates.GetLength(1); k++)
                {
                    // search for free slot
                    if (fieldCoodinates[i, k] == true)
                    {
                        planes.Add(plane);
                        plane.X = i;
                        plane.Y = k;
                        fieldCoodinates[i, k] = false;
                        Console.WriteLine("{0} says: {1} added to our control center on coordinates x:{2} - y:{3}!", this.GetType().Name, plane.Name, plane.X, plane.Y);
                        return;
                    }
                }
            }

            Console.WriteLine("{0} says: To much traffic try to join later...", this.GetType().Name);
        }
Exemplo n.º 5
0
 public void Register(AirCraftMachine plane)
 {
     plane.Mediator = this;
 }
Exemplo n.º 6
0
 public override void AllowToLand(AirCraftMachine plane)
 {
     this.fieldCoodinates[plane.X, plane.Y] = true;
     planes.Remove(plane);
     Console.WriteLine("{0} says: {1} removed from our control center movement.", this.GetType().Name, plane.Name);
 }
Exemplo n.º 7
0
 public abstract void Communicate(AirCraftMachine plane, int x, int y);
Exemplo n.º 8
0
 public abstract void AddToControlCenter(AirCraftMachine plane);
Exemplo n.º 9
0
 public abstract void AllowToLand(AirCraftMachine plane);
Exemplo n.º 10
0
 public override void AllowToLand(AirCraftMachine plane)
 {
     this.fieldCoodinates[plane.X, plane.Y] = true;
     planes.Remove(plane);
     Console.WriteLine("{0} says: {1} removed from our control center movement.", this.GetType().Name, plane.Name);
 }
Exemplo n.º 11
0
 public void Register(AirCraftMachine plane)
 {
     plane.Mediator = this;
 }