public static void Main() { Game game = new Game(); Rat rat = new Rat(game); Rat rat2 = new Rat(game); Rat rat3 = new Rat(game); WriteLine($"Rat1 attack {rat.Attack}"); WriteLine($"Rat2 attack {rat2.Attack}"); WriteLine($"Rat3 attack {rat3.Attack}"); //should be 3 rat.Dispose(); WriteLine($"\nRat2 attack {rat2.Attack}"); WriteLine($"Rat3 attack {rat3.Attack}"); //should be 2 }
static void Main(string[] args) { var g = new Game(); var r1 = new Rat(g); var r2 = new Rat(g); var r3 = new Rat(g); r1.RatAttack(); Console.WriteLine(); r2.Dispose(); r3.RatAttack(); Console.WriteLine(); }