private Playstation GetNewPlaystation() { Playstation playstation = new Playstation(); objPool.Enqueue(playstation); return(playstation); }
protected Playstation RetrieveFromPool() { Playstation playstation; if (objPool.Count > 0) { playstation = (Playstation)objPool.Dequeue(); Playstation.ObjectCounter--; } else { playstation = new Playstation(); } return(playstation); }
static void Main(string[] args) { Pool p = new Pool(); for (int i = 0; i < 10; i++) { if (playstationNum > 3 && Playstation.ObjectCounter >= 3) { takeGive = Console.ReadLine(); playstationNum--; i--; } Playstation playstation = p.GetPlaystation(); playstationNum++; } Console.Read(); }