コード例 #1
0
        private void AcceptDamageOn(ICoordinate coordinate)
        {
            int damagedSlotNumber = this.Location.GetIndex(coordinate);

            if (damagedSlotNumber == 1)
            {
                this.Slot1 = null;
            }

            else if (damagedSlotNumber == 2)
            {
                this.Slot2 = null;
            }

            else if (damagedSlotNumber == 3)
            {
                this.Slot3 = null;
            }

            else if (damagedSlotNumber == 4)
            {
                this.Slot4 = null;
            }

            else if (damagedSlotNumber == 5)
            {
                this.Slot5 = null;
            }
        }
コード例 #2
0
 public TestShip(
     string name,
     Location location,
     IFitInSocket slot1,
     IFitInSocket slot2
     )
     : this(name, location, slot1, slot2, new EmptySlot(), new EmptySlot(), new EmptySlot())
 {
 }
コード例 #3
0
        public BattleShip(Location location)
        {
            this.Location = location;

            this.Slot1 = new EmptySlot();
            this.Slot2 = new EmptySlot();
            this.Slot3 = new EmptySlot();
            this.Slot4 = new EmptySlot();
            this.Slot5 = new EmptySlot();
        }
コード例 #4
0
        public void AddTestCaptain(Location location, IFitInSocket captain, string captainnaam)
        {
            IFitInSocket canon = new TestCanon(new List <ICoordinate>()
            {
                new Coordinate(1, 1)
            });

            BattleShip albatros = new TestShip(captainnaam, location, captain, canon);

            TheSea.AcceptShip(albatros);
        }
コード例 #5
0
        public TestShip(
            string name,
            Location location,
            IFitInSocket slot1,
            IFitInSocket slot2,
            IFitInSocket slot3,
            IFitInSocket slot4,
            IFitInSocket slot5
            )
            : base(location)
        {
            Name = name;

            this.Slot1 = slot1;
            this.Slot2 = slot2;
            this.Slot3 = slot3;
            this.Slot4 = slot4;
            this.Slot5 = slot5;
        }