Пример #1
0
    public Zombie GetZombie()
    {
        /*
         *  NOTICE:
         *  In your code, make sure to check the spawn limit.
         *  you can either:
         *      1. Throw an exception
         *      2. Return null
         *      3. Spawn a new zombie anyways.
         *
         *      We'll return null.
         */

        if (this.numberActive >= spawnCap)
        {
            return(null);
        }

        if (this.numberReserved == 0)
        {
            Zombie tmp = new Zombie();
            this.reserveList.Add(tmp);
            this.numberReserved++;
        }

        Zombie zomb = this.reserveList[0];

        this.reserveList.RemoveAt(0);
        this.numberReserved--;

        this.activeList.Insert(0, zomb);
        this.numberActive++;

        zomb.Clean();

        return(zomb);
    }